On Feb 4, 2013, at 11:26 AM, Seth Willits <sli...@araelium.com> wrote:
> Exception Type:  EXC_BREAKPOINT (SIGTRAP)
> Exception Codes: 0x0000000000000002, 0x0000000000000000
> 
> *** NSTask: Task create for path 
> '/Applications/App.app/Contents/Resources/mytask' failed: 22, "Invalid 
> argument". Terminating temporary process.
> *** multi-threaded process forked ***
> 
> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
> 0   com.apple.Foundation              0x978142d8 
> ___NEW_PROCESS_COULD_NOT_BE_EXECD___ + 7
> 1   com.apple.Foundation              0x976d2e16 -[NSConcreteTask 
> launchWithDictionary:] + 4698
> 2   com.apple.Foundation              0x97744447 -[NSConcreteTask launch] + 40
> 
> What I can't figure out is what the error message means. I imagine it's 
> coming from a call to exec(), but which argument is invalid is beyond me. The 
> path to the task is correct. If the task wasn't in the app bundle, it'd be 
> seriously broken, but also if I try to replicate it by using a bad path, it 
> does crash this way, it simply throws a normal exception which is caught. The 
> arguments I pass to the task are always simple trivial strings, nothing wacky.
> 
> Looking around the open source code for exec(), it appears EINVAL (22) can be 
> returned if the task was exec()'d when not called from a vfork()'d process, 
> with the comment /* If we're not in vfork, don't permit a mutithreaded task 
> to exec */ which seems to line up with the *** multi-threaded process forked 
> *** line in the crash log…  trouble is I have no idea what this ultimately 
> means to me. Seems like an OS bug?

Does your crash log show multiple threads? I would expect that the crash log 
shows only one thread because NSTask called fork() already. That in turn would 
suggest that the EINVAL is coming from somewhere else.

NSTask's implementation might also be using fork() + posix_spawn() in your OS 
version. You should look for possible EINVAL errors from posix_spawn().


> - It crashes instead of throwing an exception — not exactly friendly.

The error occurred in the child process on the other side of the fork(). Note 
that your app didn't crash as far as the user could see; only the new child 
crashed. It would be difficult to communicate a post-fork() error to the parent 
process in order to throw an exception in the parent.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to