Re[2]: [Gc] Reproducible bug report for thread registration
Ivan Maidanski
ivmai at mail.ru
Wed Oct 31 08:13:19 PST 2012
Hi Juan,
I've launched your test on Linux:
Bad stack base in GC_register_my_thread
This statement is incorrect:
int name;
switch (GC_register_my_thread((void*)&name)) {
Your usage pattern of GC_register_my_thread is wrong (leading to unstable app behavior), the correct is:
foo() { // passed to pthread_create
GC_call_with_stack_base(foo2, NULL);
}
foo2(GC_stack_base *psb) {
int gcAttached; // it could be declared as thread-local if desired
gcAttached = GC_register_my_thread(psb) == GC_SUCCESS;
// do work
if (gcAttached) GC_unregister_my_thread();
}
Regards,
Ivan
Wed, 31 Oct 2012 19:47:30 +0400 Ivan Maidanski <ivmai at mail.ru>:
>
>
>
>
>
Hi Juan,
>
>I haven't tied it yet but could you please explain your code snippet:
>
>import_current_thread()
>{
> GC_word *key_buffer = 0;
> switch (GC_register_my_thread((void*)&name)) {
>...
> case GC_DUPLICATE:
> /* Thread was probably created using the GC hooks
> * for thread creation */
> pthread_setspecific(key, (void*)0);
> break;
> }
> if (key) {
>...
> key_buffer[0] = (GC_word)buffer;
> }
>}
>
>main() {
>...
> pthread_key_create(&key, NULL);
>...
>}
>
>To my understanding, it should crash in case pthread_create has been intercepted (because key_buffer is NULL).
>
>Also "if (key)" is a non-portable operation because pthread_key_t is opaque.
>
>Regards,
>Ivan
>
>Tue, 30 Oct 2012 22:12:02 +0100 Juan Jose Garcia-Ripoll <juanjose.garciaripoll at gmail.com>:
>
>>
>>
>>
>>
>>This reproduces what I mentioned before about thread registration.
>>
>>
>>Just use "make" and see the program fail.
>>
>>
>>The code breaks in the garbage collector library with a bus or segmentation fault. The example attached does not use ECL in any way and I tested it with a recent version of the collector.
>>
>>
>>Note that with a smaller number of threads it sometimes runs fine.
>>
>>
>>Juanjo
>>
>>--
>>Instituto de Física Fundamental, CSIC
>>c/ Serrano, 113b, Madrid 28006 (Spain)
>>http://juanjose.garciaripoll.googlepages.com
>>
>>_______________________________________________
>>
Gc mailing list
>>Gc at linux.hpl.hp.com
>>http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>>
>
>_______________________________________________
>
Gc mailing list
>Gc at linux.hpl.hp.com
>http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20121031/e5fcdd99/attachment.htm
More information about the Gc
mailing list