• 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
Re: NSTask Explodes. Clueless.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask Explodes. Clueless.


  • Subject: Re: NSTask Explodes. Clueless.
  • From: Greg Parker <email@hidden>
  • Date: Tue, 05 Feb 2013 06:23:31 -0800

On Feb 4, 2013, at 11:26 AM, Seth Willits <email@hidden> 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     email@hidden     Runtime Wrangler



_______________________________________________

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: NSTask Explodes. Clueless.
      • From: Seth Willits <email@hidden>
References: 
 >NSTask Explodes. Clueless. (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: NSDocument packages and incremental writing using NSFileWrapper
  • Next by Date: Re: NSDocument packages and incremental writing using NSFileWrapper
  • Previous by thread: NSTask Explodes. Clueless.
  • Next by thread: Re: NSTask Explodes. Clueless.
  • Index(es):
    • Date
    • Thread