[Gc] Segfault during parallel collection

Juan Wajnerman <[email protected]> Sat, 9 Aug 2014 20:36:46 -0300
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <[email protected]>
I'm having trouble combining parallel gc with coroutines made with libpcl (http://xmailserver.org/libpcl.html).
To allow the gc to deal with the coroutine stacks I register a callback with GC_set_push_other_roots. Whenever a coroutine starts or stops the GC_stackbottom is replaced. Only the portions of the coroutine stacks that are actually used are lately pushed when the "push_other_roots" callback is invoked.

This seems to work fairly well most of the time, but sometimes seems like something is not properly initialized and it crashes with the following backtrace:

0   libgc.1.dylib                 	0x0000000104392d9b GC_do_parallel_mark + 28
1   libgc.1.dylib                 	0x0000000104392249 GC_mark_some + 422
2   libgc.1.dylib                 	0x000000010438b58d GC_stopped_mark + 119
3   libgc.1.dylib                 	0x000000010438b4b1 GC_try_to_collect_inner + 260
4   libgc.1.dylib                 	0x000000010438c292 GC_collect_or_expand + 188
5   libgc.1.dylib                 	0x000000010438c48a GC_allocobj + 167
6   libgc.1.dylib                 	0x0000000104390ba9 GC_generic_malloc_inner + 350
7   libgc.1.dylib                 	0x0000000104391bb7 GC_generic_malloc_many + 977
8   libgc.1.dylib                 	0x0000000104398aa3 GC_malloc_atomic + 135
...


The reason I suspect the problem is with the initialization is because during a stress test the crash occurs very early in the first grabage collection or it doesn't happen at all even after tens of GBs are allocated and freed.
The stress test only runs on a single thread, entering and leaving many coroutines that allocate memory. This problem doesn't occur if I run the test using GC_NPROCS=1

It's complicated to give an example because it's not even C/C++ code. I'm working on a new programming language. However you can get an idea of what I'm trying to do reading this code: https://github.com/manastech/crystal/blob/master/src/fiber/pcl.cr#L102

Any ideas? Should I place some lock around the "push_other_roots" initialization?

Thanks!
- Juan Wajnerman

_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc