Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 759a07b5cb770e47d979994ca609d3c5575672fc
Ticket: 858493ffffffffffffffffffffffffffffffffff
Win32: DllMain needs SEH around Tcl_Finalize()
User & Date: davygrvy on 2003-12-11 20:03:31
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    If Tcl is being unloaded by the OS from Tcl_Panic's 
    ExitProcess(), and Tcl_Panic was called from an 
    __except block due to a crash, calling Tcl_Finalize is 
    unsafe.  IOW, DllMain should protect the call to 
    Tcl_Finalize to ensure it won't throw an unhandled 
    exception as we can't guarentee Tcl is always being 
    unloaded from a stable condition.
    
    I found this experimenting with running Tcl from a __try 
    block and calling Tcl_Panic in the __except handler:
    
    // enter Tcl's notifier and don't fall-out until 
    the thread is
    // told to quit.
    
    // If a fatal exception happens, catch it and by 
    setting the
    // async token to NULL, render QueueJob() 
    non-functional.
    //
    __try {
        __try {
    while (!done) {
        // *ALL* of Tcl runs from this loop.
        Tcl_DoOneEvent
    (TCL_ALL_EVENTS);
    }
    Tcl_AsyncDelete(*token);
    Tcl_Finalize();
    FreeLibrary(hTclMod);
        }
        __finally {
    *token = 0L;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ....
        Tcl_Panic("big crash");
    }
    
    I couldn't place FreeLibrary in the __finally as it was 
    causing exceptions itself from Tcl_Finalize in the 
    DllMain.  Yet, when my panicProc calls ExitProcess, the 
    same thing happens.  I added a change just yesterday 
    to WishPanic() on the 84branch:
    
        __try {
    ExitProcess(EXIT_FAILURE);
        } __except (EXCEPTION_EXECUTE_HANDLER) {
    TerminateProcess(GetCurrentProcess(), 
    EXIT_FAILURE);
        }
    
    
    but I think I need to back it out and address the problem 
    here in Tcl.
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "davygrvy"
  9. subsystem changed to: "None"
  10. title changed to: "DllMain needs SEH around Tcl_Finalize()"
  11. type changed to: "Patch"