[Gc] hints for debugging a multithreaded GC app on Linux...
Basile Starynkevitch <[email protected]>
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <[email protected]> |
Hello All,
I'm coding the (pre-alpha) MELT monitor on https://github.com/bstarynk/monimelt
It is buggy and multi-threaded but using Boehm's GC. It wants to have a web
interface (on localhost), using Ajax techniques
(jquery based, but jquery is packaged inside my application so no external
files are needed).
It wants to generate C code, compile it, and dlopen it...
My system is Debian/Sid/x86-64. The libgc-dev package is
libgc-dev:amd64 1:7.2d-6 amd64
I have a funny bug (very probably mine), to reproduce it:
fetch monimelt from github; I'm talking of the latest commit f6f761da396787df1f667637d0837967df2ca0f6; follow the build instructions
in the README.md there
(you'll need libonion, which sadly is not packaged on Debian).
go into the monimelt directory, make it, and run
./monimelt -D run,web -W localhost:8086 -J 2
the -D run,web option produces a lot of debugging output.
Then open a recent browser (e.g. firefox) on http://localhost:8086/
click on the routine... menu (third button from left),
selecting the compile all item... That crashes my thing
The funny thing is that the crashing thread is not running any of my code, according to gdb.
#0 0x00007f82421566ab in ?? () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#1 0x00007f82421567b8 in GC_destroy_thread_local () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#2 0x00007f824215728d in GC_unregister_my_thread_inner () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#3 0x00007f8242157944 in GC_thread_exit_proc () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#4 0x00007f8242156ba1 in GC_inner_start_routine () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#5 0x00007f8242151e72 in GC_call_with_stack_base () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#6 0x00007f82408a0062 in start_thread (arg=0x7f8238ffe700) at pthread_create.c:312
#7 0x00007f82400ccbfd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
I suspect (but I am not sure) that the fault happens
at the GC_unregister_my_thread(), perhaps in my run.c line 196
I actually don't understand well how to use Boehm GC in a multi-threaded Linux application. I've heard two different things:
1. Boehm GC is thread-friendly and thread-compatible on Linux/x86-64,
so nothing special has to be done.
2. Multi-threading should always use the GC_register_my_thread() & GC_call_with_stack_base trick.
Actually, I have a compile time macro which does enable or disable that.
It is my MOM_EXPLICIT_GC_THREAD in monimelt.h which is currently enabled,
so I'm doing the GC_register_my_thread & GC_call_with_stack_base trick.
Libonion is also starting threads, but the routine which it is starting is my
process_request from web-onion.c:50 which does not allocate using the GC
till after a GC_call_with_stack_base (line web-onion.c:110).
Any advices on how to hunt GC related bugs (probably mine!)
on a multi-threaded application on Linux?
I guess I might have done some GC_malloc with a wrong size (but I am not sure at all).
BTW, I am carefully call pthread_setname_np for all my threads,
but I can't figure out how to get GDB displaying that name!
Regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***