4

I am facing this issue in my application which is multi-threaded.

Main thread spawns another thread which is doing some memory allocation internally.

//Main thread
if(p) {
   Thread th1(TestFunc, 0);
}

//TestFunc in thread.
unsigned long TestFunc (void * param)
{

     //Do some memory allocation.

}

It looks like both the thread are waiting for each other.

Callstack for the main thread is:

_OSSpinLockLockSlow
GMFree
operator delete (void *)
Thread:: ~Thread ()
Thread:: ~Thread ()

For the spawned thread

 _OSSpinLockLockSlow
 GMmalloc_zone_malloc_internal

This is the sample code of the problem.

It looks like both main thread and spawned thread are waiting for each other.

What is the cause of this _OSSpinLockLockSlow?

doptimusprime
  • 9,115
  • 6
  • 52
  • 90
  • Is this a problem when GuardMalloc (a memory diagnostic) is *disabled*? – justin Jul 10 '13 at 10:46
  • It is independent of this. Even GuardMalloc is enabled, this problem exists. – doptimusprime Jul 10 '13 at 10:47
  • you may need to step through the program to find out more. spin locks can be extra problematic on single processor systems -- depends on the scheduler. – justin Jul 10 '13 at 11:56
  • This is not a consistent problem. This occurs sometime when Enter key is pressed too fast. So while stepping, I cannot predict when this problem will occur. – doptimusprime Jul 10 '13 at 11:57
  • Did you ever find the solution to this? – Just a coder Apr 21 '15 at 19:44
  • @Jai: Not so far. I have left my company where I was working on this few months back. – doptimusprime Apr 22 '15 at 03:02
  • @Jai, I can't help feeling there is an under-the-hood connection with [this recently surfaced issue with XCode 6.3.1/iOS8.3](http://stackoverflow.com/questions/30269243/application-sticks-on-osspinlocklockslow/30333203#30333203) - same apparent pattern. main thread and spawned threads waiting for each other on thread deletion. – foundry May 20 '15 at 00:38

0 Answers0