Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does "__workq_kernreturn" indicate in an iOS crash log or when you pause execution of an app?

When debugging on iOS, if I pause execution I often see multiple references to "__workq_kernreturn".

If my app happens to crash, I often see multiple threads identified as below:

Thread 19:
0   libsystem_kernel.dylib              0x332d0cd4 __workq_kernreturn + 8

Thread 20:
0   libsystem_kernel.dylib              0x332d0cd4 __workq_kernreturn + 8

Thread 21:
0   libsystem_kernel.dylib              0x332d0cd4 __workq_kernreturn + 8

Does "__workq_kernreturn" indicate a thread that is waiting to exit, or a thread that is deadlocked? Is this something to be worried about?

like image 775
Vik Avatar asked Feb 03 '12 14:02

Vik


1 Answers

It's nothing to worry about unless there are lots of them. If there are lots, that suggests you may be spawning more threads than you probably should, but the workq_kernreturn is still not a problem itself. It usually means that the thread is finishing. The source for it is available at opensource.apple.com if you want to take a look at what it does.

The most common stack you're probably looking at is this one:

_workq_kernreturn
_pthread_wqthread
start_wqthread

Because of optimizations, you don't see the call to _pthread_workq_return() in there, but that's what's actually happening. _workq_kernreturn is just waiting for for the spinlock to finish so it can run the next thing on its queue (or exit).

like image 66
Rob Napier Avatar answered Oct 10 '22 19:10

Rob Napier