[Gc] GC_INIT? Threads?

Bruce Hoult bruce at hoult.org
Mon Aug 19 21:35:51 PDT 2013


That's not a crash, it's a deliberate abort because some sanity-checking
code found that your world was insane. There are several things that can go
wrong inside GC_push_all_stacks, so it would be helpful to have the message
that GC_abort() printed.

However, you should always call GC_INIT() from your main program, and as
early as possible.

On some versions and platforms GC_INIT() installs code that registers
threads in a GC data structure because it's not possible to ask the OS for
all your threads. If you call GC_INIT() from a new thread on those
platforms then that thread will remain unregistered, which is one of the
things that will make GC_push_all_stacks abort later.



On Tue, Aug 20, 2013 at 4:10 PM, The Devils Jester <
thedevilsjester at gmail.com> wrote:

> I have a library that makes heavy use of of the GC, and it works quite
> well when everything (the app, and the library) is in one thread.  I call
> GC_INIT in the app, and all is well.
>
> If, however, the app creates a new thread that calls the library function,
> then it crashes when the GC does its magic (below I have pasted some
> relevant output).
>
> Is there some trick to using GC on a separate thread?  Do I call GC_INIT
> from the main thread, or the one that calls the library functions?
>
>
> 0   libsystem_kernel.dylib         0x00007fff8ad14212 __pthread_kill + 10
> 1   libsystem_c.dylib             0x00007fff90d01b54 pthread_kill + 90
> 2   libsystem_c.dylib             0x00007fff90d45dce abort + 143
> 3   libgc.1.dylib                 0x000000010357676e GC_abort + 97
> 4   libgc.1.dylib                 0x000000010357b413 GC_push_all_stacks +
> 285
> 5   libgc.1.dylib                 0x000000010357396e GC_mark_some + 377
> 6   libgc.1.dylib                 0x000000010356d73e GC_stopped_mark + 148
> 7   libgc.1.dylib                 0x000000010356d645
> GC_try_to_collect_inner + 245
> 8   libgc.1.dylib                 0x000000010356e302 GC_collect_or_expand
> + 147
> 9   libgc.1.dylib                 0x000000010356e51a GC_allocobj + 228
> 10  libgc.1.dylib                 0x0000000103572515
> GC_generic_malloc_inner + 249
> 11  libgc.1.dylib                 0x00000001035725dd GC_generic_malloc +
> 79
> 12  libgc.1.dylib                 0x00000001035728c0 GC_core_malloc + 196
>
> --
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <https://www.mailscanner.info/>, and is
> believed to be clean.
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://napali.hpl.hp.com/pipermail/gc/attachments/20130820/ed2a9c7e/attachment.htm


More information about the Gc mailing list