垃圾收集工作队列崩溃,如果dylib加载 [英] Crash of Garbage Collection Work Queue if dylib is loaded

查看:191
本文介绍了垃圾收集工作队列崩溃,如果dylib加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从10.6到10.8移植一个应用程序。我正在查看我们在应用中加载的dylib。

  malloc:Thread:垃圾收集工作队列 :suspend():无法挂起线程:err = 268435459,线程0x111000000:_pthread = 0x108129000,_thread = 0x8b07,_stack_base = 0x108129000,活跃,0本地块

对于应用程序设置GCC_ENABLE_OBJC_GC = required 。如果我在dylib中有 GCC_ENABLE_OBJC_GC = required ,它仍会崩溃。我无法在应用程序中关闭垃圾收集器。我必须从我的dylib管理它崩溃。



崩溃的原因原来是垃圾收集器无法挂起线程。 (正如它在日志中所说)。此线程使用 thread_create()创建。如果我在dylib的构造函数中放入一个无限循环(带睡眠),我不会崩溃。当构造函数完成执行时,我会崩溃。



他们是否告诉垃圾收集器不要尝试挂起线程?或者增加线程的引用计数?或者我可以做的任何事情来阻止垃圾回收器不会干扰我的dylib代码。

解决方案

 预期。 
从OSX 10.8开始,垃圾回收已被弃用。因此,CG无法暂停执行其职责。因此,您可以获得所有您遇到的问题。

如果要开发10.8,则需要转换为ARC(最佳)或返回到手动引用计数。如果您希望移动到arc,请参阅转换到ARC发行说明

从Apple文档约10.8: / p>

重要提示:从OS X v10.8开始,弃用垃圾回收。改用ARC(自动引用计数)。要详细了解ARC,请参阅转换到ARC版本说明。

; PG = PT431&安培; LPG = PT431&安培; DQ =崩溃+的+垃圾+收集+工作+在+客观+ C&安培;源= BL&安培; OTS = xTjLETFMsO&安培; SIG = b33rLeXJVh1WtnAvcVJykfNtvOU&安培; HL = EN&安培; SA = X&安培; VED = 0ahUKEwiyqZrC2rvNAhVKNI8KHZRdC7AQ6AEIKDAC #v = onepage& q = Crash%20of%20Garbage%20Collection%20Work%20in%20objective%20c& f = falserel =nofollow> https://books.google.co.in/books?id=8nzwsciij20C& ; PG = PT431&安培; LPG = PT431&安培; DQ =崩溃+的+垃圾+收集+工作+在+客观+ C&安培;源= BL&安培; OTS = xTjLETFMsO&安培; SIG = b33rLeXJVh1WtnAvcVJykfNtvOU&安培; HL = EN&安培; SA = X&安培; VED = 0ahUKEwiyqZrC2rvNAhVKNI8KHZRdC7AQ6AEIKDAC #v = onepage& q = Crash%20of%20Garbage%20Collection%20Work%20in%20objective%20c& f = false


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.

解决方案

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

这篇关于垃圾收集工作队列崩溃,如果dylib加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆