Overview
| Artifact ID: | 531a5a36682d01c9538edb2605f2f67cf63401df |
|---|---|
| Ticket: | 1011715fffffffffffffffffffffffffffffffff
segfault in exit() due to unloaded shared library |
| User & Date: | nobody on 2004-08-18 19:38:33 |
Changes
- assignee changed to: "kennykb"
- cmimetype changed to: "text/plain"
- comment changed to:
platform: linux, gcc 2.95.3 The c-library function exit() cannot reach C++-destructors which has been registered via atexit() . This happens, because tcl8.5.xxx unloads any shared library associated with a registered package. example: ----------- t.cpp -------------------------- #include <tcl.h> class X { public: ~X() {}; }; extern "C" int T_Init( Tcl_Interp * interp ) { static X x; return TCL_OK; } --------------------------------------------- make a shared library: g++ -o libt.so -shared -fPIC -I../generic t.cpp Then, in tclsh: "load libt.so; exit" ends up with a core dump. (1) load libt.so load the dll and calls T_Init() (2) g++ registers an exit-handler calling atexit() after constructing the static object x of class X. (3) at end: TclpUnloadFile() calls dlclose() for this package (4) Tcl calls exit() (5) exit() calls the exit-handler registered in step (2), which unfortunately has been unloaded in step (3) The unload behavior is controlled by the macro TCL_UNLOAD_DLLS. The current snapshot's Makefile.in defines this macro as -DTCL_UNLOAD_DLLS=1 Having -DTCL_UNLOAD_DLLS=0 as default would ensure compatibility with previous versions (no implicit unload). -- [email protected] - foundin changed to: "obsolete: 8.5a2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "40. Dynamic Loading"
- title changed to: "segfault in exit() due to unloaded shared library"
- type changed to: "Bug"