[Gc] GC + dylibs on Darwin/OS X

Brian Alliet brian@brian-web.com
Wed, 5 Mar 2003 16:05:10 -0500


It looks like I have the GC working with dylibs on darwin. I'm  
currently working with 6.2alpha3 and Jesse Rosenstock's pthread  
patches. I can build libgc as a shared library and make check is happy  
(well most of the time at least). I also came up with a few tests of my  
own including dynamicly loading bundles (with NSLinkModule, etc) which  
all seem to work.

Basically all you have to do is create a  
GC_register_dynamic_libraries() function then call GC_add_roots_inner  
on the data, bss, and common sections of each shared library right? Let  
me know if I missed anything.

There still seem to be some problems with the threading code (from  
Jesse Rosenstock's patch). It seems like it randomly hangs every once  
and a while. To make things even more interesting, it makes gdb very  
upset.

Program received signal SIGINT, Interrupt.
0x90005148 in syscall ()
(gdb) where
#0  0x90005148 in syscall ()
#1  0x00004cc8 in GC_suspend_handler (sig=124356) at linux_threads.c:711
#2  <signal handler called>
#3  0x90031368 in swtch_pri ()
#4  0x00000000 in ?? ()
/SourceCache/gdb/gdb-250/src/gdb/macosx/ppc-macosx-frameinfo.c:702:  
internal-error: assertion failure in function  
"ppc_find_function_boundaries": reply->prologue_start != INVALID_ADDRESS

A problem internal to GDB has been detected.  Further
debugging may prove unreliable.
Quit this debugging session? (y or n)

I'm assuming this has something to do with the semaphore in the signal  
handler. One other thing I stumbled on while browsing some of the apple  
documentation was this, "With the exception of semaphore_create and  
semaphore_destroy, these functions can also be called from user space  
via RPC." on  
http://developer.apple.com/techpubs/macosx/Darwin/General/ 
KernelProgramming/synchronization/chapter_15_section_2.html. That kinda  
sounds like you aren't supposed to use semaphore_create in userspace,  
which is what the current code does.

The dylib patch is at  
http://www.brianweb.net/misc/boehm-gc-dylib.patch. Let me know if it  
works for anyone else.

-Brian