2011-05-01 27 views
2

我打這個錯誤「malloc:*** auto malloc [731]:錯誤:在未註冊的線程上的GC操作。隱式註冊的線程。在調試時斷開auto_zone_thread_registration_error()。尋求幫助,「錯誤:未註冊線程上的GC操作。隱式註冊線程。」

我的應用程序是這樣工作的,當用戶雙擊在NSTableView的一行時,它會從該行獲得一個URL,然後要求的WebView從該URL加載頁面:

[tableView setDoubleAction:@selector(doubleClickAction:)]; 
... 

- (IBAction)doubleClickAction:(id)sender { 
    ... 
    /* cause that malloc error */ 
    [[webView mainFrame] loadRequest: [NSURLRequest requestWithURL: row.url]]; 
} 

所以我怎麼修復它呢?

謝謝!

+0

您的應用程序崩潰了嗎? – 2011-05-01 22:03:55

+0

是否添加了auto_zone_thread_registration_error斷點? – 2011-05-01 23:55:05

+0

該應用不會崩潰。我是可可開發的新手,我實際上並不知道「打斷auto_zone_thread_registration_error()調試」的意思。我在該行添加了一箇中斷,在我走出線路並鍵入「bt」命令後,gdb可以打印出呼叫跟蹤,一切看起來都正常。過了一會兒,彈出錯誤,GDB不再響應bt命令。那麼我如何進一步調試? – Qiulang 2011-05-02 12:22:28

回答

1

將此objc_registerThreadWithCollector();添加到您的pthread中。如果找不到符號或鏈接錯誤,請使用以下代碼:

#include <dlfcn.h> 
    void (*registerThreadWithCollector_fn)(void); 
    registerThreadWithCollector_fn = (void(*)(void)) dlsym(RTLD_NEXT, "objc_registerThreadWithCollector"); 
    if (registerThreadWithCollector_fn) { 
     (*registerThreadWithCollector_fn)(); 
    } else { 
     // do something else 
    } 
+0

我們是否需要取消註冊?或者它會自動發生? – Amitg2k12 2013-11-06 18:33:35