Currently, uw_init_context_1 will always call init_dwarf_reg_size_table if __GTHREADS is defined but threading is not active or not actually implemented. The stub functions for __gthread_once return -1 to indicate that this functionality is unimplemented. Likewise, full implementations return -1 when threadig is not active. We will currently call init_dwarf_reg_size_table unguarded if either __gthread_once fails or dwarf_reg_size_table[0] is zero; this is bogus. If _gthread_once succeeds, we know that init_dwarf_reg_size_table has been called, so there is no need to test dwarf_reg_size_table[0], we definitely don't need to call it again. If it fails, this can be because threading is not active, so we should test dwarf_reg_size_table[0]. If that is set, it indicates that we've already called init_dwarf_reg_size_table, just like in the !__GTHREADS case. I've successfully regression tested the below patch on i686-pc-linux-gnu X sh-elf, however, that doesn't really mean all that much since this is currently not a __GTHREADS target. I can't bootstrap mainline on my host, see http://gcc.gnu.org/ml/gcc/2006-04/msg00055.html . Could someone with a __GTHREADS host which can still bootstrap test this patch? 2006-04-05 J"orn Rennecke * unwind-dw2.c (uw_init_context_1): Fix test that checks if dwarf_reg_size_table has been initialized. Index: unwind-dw2.c =================================================================== /usr/bin/diff -p -d -F^( -u -L unwind-dw2.c (revision 112638) -L unwind-dw2.c (working copy) .svn/text-base/unwind-dw2.c.svn-base unwind-dw2.c --- unwind-dw2.c (revision 112638) +++ unwind-dw2.c (working copy) @@ -1370,7 +1370,7 @@ uw_init_context_1 (struct _Unwind_Contex { static __gthread_once_t once_regsizes = __GTHREAD_ONCE_INIT; if (__gthread_once (&once_regsizes, init_dwarf_reg_size_table) != 0 - || dwarf_reg_size_table[0] == 0) + && dwarf_reg_size_table[0] == 0) init_dwarf_reg_size_table (); } #else