• 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: -[NSThread start] blocks ?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSThread start] blocks ?!?


  • Subject: Re: -[NSThread start] blocks ?!?
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 27 Sep 2015 05:49:30 -0500

On Sep 26, 2015, at 5:33 PM, Jerry Krinock <email@hidden> wrote:

> In a OS X app, predating Grand Central Dispatch, in the main thread, I create and start a new thread
>
> NSThread* worker ;
> worker = [[NSThread alloc] initWithTarget:instance
>                                 selector:@selector(beginWithInfo:)
>                                   object:info] ;
> [worker setName:@“My Worker thread"] ;
> [worker start] ;
>
> usually this works OK, but sometimes, possibly when the above code executes a second or third time in rapid succession, [worker start] will block forever:

> Looking at the other threads, I see that “My Worker thread” (see Thread 455, below) has been created, and seems to be stuck while trying to *exit*, which I think is weird because if -[NSThread start] blocked until the new thread exitted, that would defeat the purpose of multithreading.  Same thing if, say, My Worker thread executed some kind of “do this on the main thread” call.
>
> Should not -[NSThread start] always return before running any of my code in the new thread?  So how could this happen?  I’m running OS X 10.11.

It could be a bug in the system libraries, but it could also be any number of other things.  For example, a heap smashing bug could have corrupted a GCD-internal spin lock variable.  Try running with zombies enabled and see if you trip one.  Try building and running with Address Sanitizer.  Run the static analyzer on your code and make sure to fix any issues it identifies (or examine them thoroughly to determine that they're false positives).

You could also try to reproduce the problem with a very much simplified test app.  That would be the first step in filing a bug report, anyway.

Regards,
Ken


_______________________________________________

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


References: 
 >-[NSThread start] blocks ?!? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: -[NSThread start] blocks ?!?
  • Next by Date: Re: -[NSThread start] blocks ?!?
  • Previous by thread: Re: -[NSThread start] blocks ?!?
  • Next by thread: Re: -[NSThread start] blocks ?!?
  • Index(es):
    • Date
    • Thread