Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash of Garbage Collection Work Queue if dylib is loaded

We are porting an app from 10.6 to 10.8. I am looking at dylib we load in app. I am facing very unusual crash in Garbage Collection Work Queue with following message.

malloc: Thread::suspend():  unable to suspend a thread:  err = 268435459, Thread 0x111000000: _pthread = 0x108129000, _thread = 0x8b07, _stack_base = 0x108129000, enlivening  on, 0 local blocks

For application GCC_ENABLE_OBJC_GC = required is set. If I have GCC_ENABLE_OBJC_GC = required in dylib it will still crash. I cannot turn off garbage collector in application. I have to manage it crash from my dylib.

Reason for crash turns out to be that garbage collector is not able to suspend the thread. (as it says in log). This thread is created using thread_create(). If I put a indefinite while loop (with sleep) in constructor of dylib, I dont get crash. I get crash when constructor has finished its execution.

Is their a way to tell garbage collector not to try and suspend the thread? Or to increase reference count of thread? or anything I can do to stop garbage collector not to interfere with my dylib code.

like image 381
RLT Avatar asked Feb 11 '13 17:02

RLT


1 Answers

It is expected. 
Starting with OSX 10.8, Garbage collection is deprecated. So CG is unable to suspend the threads to perform its duty. As a result you get all the issues you are facing.

If you want to develop for 10.8, you need to convert to ARC (best) or move back to manual reference counting. If you wish to move to arc, see Transitioning to ARC Release Notes

From Apple documentation about 10.8:

Important: Beginning in OS X v10.8, garbage collection is deprecated. Use ARC (Automatic Reference Counting) instead. To learn more about ARC, see Transitioning to ARC Release Notes.

https://books.google.co.in/books?id=8nzwsciij20C&pg=PT431&lpg=PT431&dq=Crash+of+Garbage+Collection+Work+in+objective+c&source=bl&ots=xTjLETFMsO&sig=b33rLeXJVh1WtnAvcVJykfNtvOU&hl=en&sa=X&ved=0ahUKEwiyqZrC2rvNAhVKNI8KHZRdC7AQ6AEIKDAC#v=onepage&q=Crash%20of%20Garbage%20Collection%20Work%20in%20objective%20c&f=false

like image 157
Sady Sadeesh Avatar answered Oct 21 '22 11:10

Sady Sadeesh