On Jan 1, 2010, at 6:43 PM, James W. Walker wrote:
> 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?
Try turning off "Auto-attach debugger on crash" in the executable's settings
(the "executable" in the sense of Xcode's representation of your app's
executable, in its project).
I believe that Xcode may actually be attaching to the child process and not
your app. The auto-attach feature works in a way which can be inherited by
child processes. When one of those crashes, Xcode gets confused and thinks the
app it directly launched has crashed.
With auto-attaching turned off, Xcode will only catch crashes and exceptions in
your app when you explicitly launch it via the debugger, but Xcode usually
works better at showing you the result of the crash when used that way, anyway.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]