Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segfault when releasing autorelease pool



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden


This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.