guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

null-threads: keys are destroyed too early


From: Matthias Drochner
Subject: null-threads: keys are destroyed too early
Date: Wed, 27 Feb 2008 17:17:53 +0100

The "autogen" program crashes on exit if built against
a guile which doesn't use threads.
Here is a stacktrace:
#0  0xbbb902d1 in scm_make_srcprops () from /usr/pkg/lib/libguile.so.17
#1  0xbbb8b322 in scm_read_sexp () from /usr/pkg/lib/libguile.so.17
#2  0xbbb8a3f9 in scm_read_expression () from /usr/pkg/lib/libguile.so.17
#3  0xbbb8b1dc in scm_read_sexp () from /usr/pkg/lib/libguile.so.17
#4  0xbbb8a3f9 in scm_read_expression () from /usr/pkg/lib/libguile.so.17
#5  0xbbb8b1dc in scm_read_sexp () from /usr/pkg/lib/libguile.so.17
#6  0xbbb8a3f9 in scm_read_expression () from /usr/pkg/lib/libguile.so.17
#7  0x08050b3b in ag_scm_c_eval_string_from_file_line ()
#8  0x0805bbbd in doneCheck ()
#9  0xbba6b999 in __cxa_finalize () from /usr/lib/libc.so.12
#10 0xbba6b822 in exit () from /usr/lib/libc.so.12

The following happens: autogen registers an atexit() function
which calls ag_scm_c_eval_string_from_file_line().
On exit, this eventually calls scm_make_srcprops(), which
uses SCM_CRITICAL_SECTION_START, which in turn references
SCM_I_CURRENT_THREAD. The latter is implemented by
pthread_getspecific(), or rather its replacement in null-threads.c.

The emulated pthread_key_create() in null-threads.c also
registers an atexit() function which destroys the pthread_keys
allocated by the process. Since atexit() functions are
called in reverse order, this destroy_keys() function is
called before the doneCheck() above.

So SCM_I_CURRENT_THREAD tries to use a destroyed key,
leading to the crash.

The appended patch avoids the problem.

best regards
Matthias





-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------

Attachment: patch-ak
Description: patch-ak


reply via email to

[Prev in Thread] Current Thread [Next in Thread]