• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
access violation after using NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

access violation after using NSTask


  • Subject: access violation after using NSTask
  • From: "James W. Walker" <email@hidden>
  • Date: Fri, 1 Jan 2010 16:43:08 -0800

I understand that one advantage of using a task rather than a thread is a task can crash without taking down the main app.  I decided to try that.  I made a little command-line program that deliberately crashes by infinite recursion, and a Cocoa app that runs it using NSTask.  The problem is that after the task runs, a click on the menu bar makes the app crash, and this appears in the debugger console:

"Program received signal:  “EXC_BAD_ACCESS”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Cannot call into the loader at present, it is locked.)
Previous frame inner to this frame (gdb could not unwind past this frame)
Previous frame inner to this frame (gdb could not unwind past this frame)"

There is no backtrace, so I'm not sure how to get a clue of what went wrong.

Here's the task running code, which is an an app delegate object:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
	NSTask* testTask = [[NSTask alloc] init];

	[testTask setCurrentDirectoryPath: @"/"];
	[testTask setLaunchPath:
		@"/Volumes/Work/Test_projects/CrashTask/build/Debug/CrashTask"];
	[testTask setArguments: [NSArray arrayWithObject: @"foo"] ];

	@try
	{
		[testTask launch];
	}
	@catch (NSException *exception)
	{
		NSLog(@"Caught %@: %@", [exception name], [exception  reason]);
	}
}

If I comment out the line [testTask launch] then the crash does not happen.  Interestingly, if I run the app in the Finder rather than in the Xcode debugger, it doesn't crash.  Any ideas?


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: access violation after using NSTask
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: ABPerson initWithVCardRepresentation without addRecord
  • Next by Date: Re: Custom NSWindow drawing
  • Previous by thread: Re: ABPerson initWithVCardRepresentation without addRecord
  • Next by thread: Re: access violation after using NSTask
  • Index(es):
    • Date
    • Thread