Finalizer crasher on OS X

Luke Howard lukeh at padl.com
Fri Sep 24 10:03:48 EDT 2010


I don't know if this is a OS X dynamic linker problem, but I'm running into the following problem.

Some background: I have a GSS mechanism that is dynamically loaded by and is linked against the mechanism glue, libgssapi_krb5.dylib.

Then I have a Cyrus SASL plugin that links against the mechanism glue (although that isn't particularly relevant; all that's it relevant is that we have two levels of dynamic loading). I get the following crash because gssint_mechglue_fini() is called reentrantly:

Assertion failed: (destructors_set[keynum] == 1), function krb5int_key_delete, file threads.c, line 397.

Program received signal SIGABRT, Aborted.
0x00007fff806f93d6 in __kill ()
(gdb) bt
#0  0x00007fff806f93d6 in __kill ()
#1  0x00007fff80799972 in abort ()
#2  0x00007fff807869b4 in __assert_rtn ()
#3  0x00000001000c55e6 in krb5int_key_delete (keynum=K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME) at threads.c:397
#4  0x0000000100218d58 in gss_krb5int_lib_fini () at gssapi_krb5.c:831
#5  0x000000010020b836 in gssint_mechglue_fini () at g_initialize.c:123
#6  0x00007fff5fc0eae2 in __dyld__ZN16ImageLoaderMachO13doTerminationERKN11ImageLoader11LinkContextE ()
#7  0x00007fff5fc04952 in __dyld__ZN4dyld11removeImageEP11ImageLoader ()
#8  0x00007fff5fc04ba5 in __dyld__ZN4dyld20garbageCollectImagesEv ()
#9  0x00007fff5fc09e9a in __dyld_dlclose ()
#10 0x00007fff806b2ae5 in dlclose ()
#11 0x00000001000c5cc3 in krb5int_close_plugin (h=0x10010e2b0) at plugins.c:412
#12 0x000000010020e045 in freeMechList () at g_initialize.c:840
#13 0x000000010020b858 in gssint_mechglue_fini () at g_initialize.c:128
#14 0x00007fff5fc0eae2 in __dyld__ZN16ImageLoaderMachO13doTerminationERKN11ImageLoader11LinkContextE ()
#15 0x00007fff5fc048e2 in __dyld__ZN4dyld14runTerminatorsEPv ()
#16 0x00007fff806bd7f4 in __cxa_finalize ()
#17 0x00007fff806bd70c in exit ()
#18 0x000000010000129b in start ()

I can work around it by linking the executable against the libgssapi_krb5 directly, but that's not shippable. At runtime, setting DYLD_INSERT_LIBRARIES to the path to libgssapi_krb5 also works, but that's not ideal either.

If it's an OS X bug, fine, otherwise I wonder if we can workaround it by having the destructor set did_run = 0.

-- Luke


More information about the krbdev mailing list