Segfault when releasing autorelease pool
Segfault when releasing autorelease pool
- Subject: Segfault when releasing autorelease pool
- From: Sean McGroty <email@hidden>
- Date: Sun, 30 Oct 2005 22:28:32 -0500
I'm working on a framework and am encountering a frustrating problem.
When I attempt to free the autorelease pool, the program crashes with
a segmentation fault.
It has to be related to the initWithSerialDeviceFileName code, as
allocating and initializing the base class of GDFreestyleMeter,
GDMeter, works properly. Specifically, the problem appears to center
on the "meterDevice = [NSFileHandle
fileHandleForUpdatingAtPath:deviceFile];" line in
initWithSerialDeviceFileName, as commenting that out allows the
program to quit successfully, at the cost of not doing anything useful.
What am I doing wrong?
My main.m file:
#import <Foundation/Foundation.h>
#import "GDFreestyleMeter.h"
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
GDFreestyleMeter* testMe = [[GDFreestyleMeter alloc]
initWithSerialDeviceFileName:[NSString stringWithUTF8String:argv[1]]];
[testMe release];
[pool release];
return 0;
}
The initWithSerialDeviceFileName code:
- (id)initWithSerialDeviceFileName:(NSString*)deviceFile
{
if(self = [super init])
{
meterDevice = [NSFileHandle
fileHandleForUpdatingAtPath:deviceFile];
if(meterDevice == nil)
{
NSException* noFile = [NSException
exceptionWithName:@"SerialPortDoesNotExistException" reason:@"The
serial port specified does not exist" userInfo:[NSDictionary
dictionaryWithObject:deviceFile forKey:@"devicePath"]];
[noFile raise];
}
[self setSerialPortOptions];
}
return self;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden