 |
 |
Exc_bad_access
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
I am trying to get some Rendezvous sharing working in my program. Things seem to be going okay. I can get the two computers to see each other and register the services and I can even get one computer to send the data to the other and it gets processed properly on the client end. The problem is that the server quits with SIG 11 immediately after closing the connection. I turned on the debugger and it gives me an EXC_BAD_ACCESS message and puts a red hightlight around main:
Code:
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}
The last bit of server code to function as far as I can tell is this:
Code:
- (void)connectionReceived:(NSNotification *)aNotification {
NSLog(@"connection received");
NSFileHandle * incomingConnection = [[aNotification userInfo] objectForKey:NSFileHandleNotificationFileHandleItem];
NSLog(@"nsfilehandle established");
NSLog(@"machineName=%@,%d,%@,%d,%@",[localMachine machineName],[localMachine progress],[localMachine estimatedTimeOfCompletion],[localMachine secondProgress],[localMachine secondEstimatedTimeOfCompletion]);
NSString *serverInfo = [NSString stringWithFormat:@"%@,%d,%@,%d,%@", [localMachine machineName],[localMachine progress],[localMachine estimatedTimeOfCompletion],[localMachine secondProgress],[localMachine secondEstimatedTimeOfCompletion]];
NSLog(@"finished serverinfo");
NSLog(@"serverInfo=%@",serverInfo);
NSData *serverInfoData = [NSData dataWithBytes:[serverInfo UTF8String]
length:[serverInfo length]];
NSLog(@"NSData made");
[[aNotification object] acceptConnectionInBackgroundAndNotify];
[incomingConnection writeData:serverInfoData];
[incomingConnection closeFile];
[incomingConnection release];
NSLog(@"end connection received");
}
That last NSLog is posted just fine. Any ideas where to look? I'm new to the debugger so I don't really know how to assess its output very well.
thanks,
kman
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2001
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Thank you. I didn't actually have to do what was suggested on that page, but it was a great read and caused me to just remove that release statement at the end of the that method and now it works great.
kman
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2000
Status:
Offline
|
|
Originally posted by kman42:
Thank you. I didn't actually have to do what was suggested on that page, but it was a great read and caused me to just remove that release statement at the end of the that method and now it works great.
The reason you didn't need to release the NSFileHandle was that you didn't acutally allocate it yourself with the alloc, new, or copy families then you don't need to release it. If you send it a retain however, then you need a corresponding release or autorelease.
For a full discussion of Memory Management and Object Ownership in Cocoa, see Apple's developer documentation, the same file is also in the Developer Tools documentation on your hard disk:
/Developer/Documentation/Cocoa/TasksAndConcepts/ProgrammingTopics/MemoryMgmt/Concepts/ObjectOwnership.html
- proton
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Status:
Offline
|
|
I had the same problem probably 5 or 6 times before I finally got the hang (sort of) of what to retain and what not to. It caused me no end of pain before I learned about NSZombie.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|