#6793: Issues with __cxa_atexit --------------------------------+------------------------------ Reporter: kaliber | Owner: axeld Type: bug | Status: closed Priority: normal | Milestone: R1 Component: System/libroot.so | Version: R1/Development Resolution: fixed | Keywords: Blocked By: | Has a Patch: 0 Platform: All | Blocking: --------------------------------+------------------------------ Comment (by bonefish): Replying to [comment:5 kaliber]: > In my opinion tool chain call looks fine: Nope, it doesn't. As you can see the object is linked with `/boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-100705/lib/gcc/i586-pc- haiku/4.4.4/crtbegin.o`. That file belongs to the gcc distribution. It contains the function `__do_global_dtors_aux()` which would call `__cxa_finalize()`, '''if''' gcc would register any destructors via `__cxa_atexit()`. Since our gcc currently doesn't do the latter it also doesn't do the former. If clang uses `__cxa_atexit()`, it has to make sure that `__cxa_finalize()` is called -- it therefore cannot use gcc's `crtbegin.o`. At least not until we enable that feature in gcc as well. > Shouldn't dlclose() call/register "atexit"? LSB specification http://refspecs.freestandards.org/LSB_3.2.0/LSB-Core-generic/LSB-Core- generic/baselib---cxa_finalize.html says: "The implementation shall arrange for _cxa_finalize() to be called during early shared library unload (e.g. dlclose()) with a handle to the shared library". The term "implementation" in the Itanium C++ ABI specification mainly refers to the compiler/tool chain. In this case gcc definitely seems to feel responsible as it calls `__cxa_finalize()` in its [http://dev.haiku- os.org/browser/buildtools/trunk/gcc/gcc/crtstuff.c#L281 crtstuff.c]. We just don't build the `crtbegin.o` version which would do that. -- Ticket URL: <http://dev.haiku-os.org/ticket/6793#comment:6> Haiku <http://dev.haiku-os.org> Haiku - the operating system.