Search code examples
iosios8nsoperationmach

thread_info returns MACH_SEND_INVALID_DEST instead of KERN_SUCCESS


A call to thread_info now returns MACH_SEND_INVALID_DEST instead of KERN_SUCCESS and I don't yet understand what has caused this new circumstance.

What could be the reason for this return value. I pass a valid obtained from mach_thread_self() when called inside an NSOperation as thread_act_t (i.e first parameter). At the time when the call to thread_info() is made the operation may have completed but its NSOperationQueue is still retained. Is it that NSOperation may have executed on a thread that no longer exists at the time of the call?

Basically I want to find out how long the operation took in terms of the thread's user and system time. The operation invokes an asynchronous service at its tail, thread_info() is called from that service's completion handler.


Solution

  • I now wait for an NSCondition inside the NSOperation (after it invoked the asynchronous service, i.e. at its very end) and signal it in the completion handler. That seems to have resolved the issue.