Ticket #63 (closed defect: fixed)
[PATCH] libusb pthread usage causes error in garbage collected Cocoa apps
|Reported by:||rogueresearch||Owned by:||hjelmn|
When libusb is used in a Mac OS X Cocoa application that uses garbage collection, an error is logged by the OS:
malloc: * auto malloc: error: GC operation on unregistered thread. Thread registered implicitly. Break on auto_zone_thread_registration_error() to debug.
Anyway, the fix is easy: Whenever libusb creates a pthread, that thread must register itself with the garbage collector by calling objc_registerThreadWithCollector().
I am testing a patch currently...
Note that this will require linking to an additional lib, namely libobjc.dylib. I wouldn't worry about that though, because libusb already links to CoreFoundation?.framework, which as you can see below, already links to libobjc:
$ otool -L /System/Library/Frameworks/CoreFoundation?.framework/CoreFoundation:
/System/Library/Frameworks/CoreFoundation?.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.42.0)
/usr/lib/libauto.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 40.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
comment:2 Changed 3 years ago by hjelmn
- Owner set to hjelmn
- Status changed from new to accepted
Changed 3 years ago by rogueresearch
Changed 2 years ago by rogueresearch
comment:24 Changed 20 months ago by rogueresearch
- Resolution set to fixed
- Status changed from accepted to closed