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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With