Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

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

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. 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]
    
     
    
    
        
    
    
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.5a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "40. Dynamic Loading"
  10. title changed to: "segfault in exit() due to unloaded shared library"
  11. type changed to: "Bug"