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
-------------------------------------------------------------------
-------------------------------------------------------------------
$NetBSD$
--- libguile/null-threads.c.orig 2008-01-04 14:43:50.000000000 +0100
+++ libguile/null-threads.c
@@ -47,8 +47,10 @@ int
scm_i_pthread_key_create (scm_i_pthread_key_t *key,
void (*destr_func) (void *))
{
+#if 0 /* keys are needed by other atexit() functions */
if (all_keys == NULL)
atexit (destroy_keys);
+#endif
key->next = all_keys;
all_keys = key;