Skip to content
Tcl Source Code History Of Ticket 858493ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 858493ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 858493ffffffffffffffffffffffffffffffffff

  1. Ticket change [759a07b5cb] (rid 105418) by davygrvy on 2003-12-11 20:03:31:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "davygrvy"
    9. subsystem initialized to: "None"
    10. title initialized to: "DllMain needs SEH around Tcl_Finalize()"
    11. type initialized to: "Patch"
  2. Add attachment "bang.c" [2622e42a10] (rid 88289) by davygrvy on 2003-12-12 03:03:32.

  3. Ticket change [997ca29f87] (rid 110805) by davygrvy on 2003-12-12 03:03:32:

    1. icomment:
      
      
      File Added - 70280: bang.c
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  4. Ticket change [64051f77ff] (rid 92679) by davygrvy on 2003-12-12 03:11:16:

    1. assignee changed to: "mdejong"
    2. icomment:
      
      
      File Added - 70281: seh_dllmain_patch.txt
      
      Logged In: YES 
      user_id=7549
      
      Mo, could have a look at the patch for the HAVE_NO_SEH 
      part.  I copied from the others, but I don't if it works under 
      cygwin, and probably could do much if it wasn't working 
      correctly anyways.
      
      Then again, I'm not sure if this is the correct direction to 
      stablize a Tcl_PanicProc.  It seems more correct not to 
      modify a Tcl_PanicProc (WishPanic) but to stabize the DllMain 
      code so it can exit given an unstable exit.
      
      
    3. login: "davygrvy"
    4. mimetype: "text/plain"
    5. subsystem changed to: "50. Embedding Support"
    6. username: "davygrvy"
  5. Add attachment "seh_dllmain_patch.txt" [93213a829b] (rid 105765) by davygrvy on 2003-12-12 03:11:16.

  6. Ticket change [cc1f48845e] (rid 95640) by dgp on 2003-12-12 05:42:29:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Just a general comment.  I think
      that experiments like this are
      worthwhile, but best done on
      the CVS HEAD, leaving the
      core-8-4-branch stable with 
      more tested code.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [718b4e0a0d] (rid 100696) by davygrvy on 2003-12-12 07:17:02:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Agreed, but 8.5 has the Tcl_Namespace problem in the Stubs 
      table and I find it too difficult to work with.  Even if I did 
      place the changes into the HEAD, I would be testing and 
      running the code in the 8.4 branch only.
      
      I'm finding some deeper problem in some of the exit handlers.  
      It looks like threads are halted and in 
      SocketThreadExitHandler for example is blocking on:
      
        WaitForSingleObject(tsdPtr->socketThread, INFINITE);
      
      Although the thread appears to be running, it isn't.  This 
      solves it:
      
          dwWait = WaitForSingleObject(tsdPtr->socketThread, 100);
          if (dwWait == WAIT_TIMEOUT) {
      /*
       * Avoids a lock-up, just in case it is needed from an
       * unclean exit condition when the thread appears
       * running, but isn't.
       */
      TerminateThread(tsdPtr->socketThread, 
      EXIT_FAILURE);
          }
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  8. Ticket change [ed93d74475] (rid 103910) by davygrvy on 2003-12-12 08:28:29:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      commited the win/tclWinSock.c change to the HEAD from 
      below and reverted the WishPanic() change in win/winMain.c 
      on the core-8-4-branch of Tk.
      
      Tcl_Finalize, although now not blocking in 
      SocketThreadExitHandler, sometimes blows chunks in a Tk 
      exit handler trying to destroy the tkCon window.  I'll study it 
      some more...
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  9. Ticket change [8f1a343cd4] (rid 120225) by davygrvy on 2003-12-12 08:47:06:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      PS.  ya know...  It's becoming a common occurance for me to 
      have problems in Tcl_Finalize.  If we do wrap DllMain's call to 
      Tcl_Finalize in SEH protection, I sure hope this won't mask 
      programming errors other developers might create in their 
      journeys of embedding.  My intent is not to mask the normal 
      route to Tcl_Finalize, but just DllMain's entry to it.
      
      Just thought I should mention this.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  10. Ticket change [723c904bc3] (rid 100823) by davygrvy on 2003-12-12 17:21:13:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Looks like Tk needs some attention, too.  Its exit handler, 
      DeleteWindowsExitProc, is called *AFTER* Tk has been 
      unloaded by the OS under exception condition, or at least 
      from the ExitProcess condition.  No wonder is goes bang.  
      This isn't surprising as DLLs are unloaded in reverse order they 
      were loaded.  If Tcl is calling exit handlers in other 
      extensions, no wonder they crash, they've all been unloaded 
      already..  They're all big dangling pointers..
      
      Now things are getting interesting :)
      
      Should Tk have it's own Tk_CreateExitHandler so it can clean 
      itself up from its DllMain given the OS is taking it down before 
      Tcl?  I think so.  I'll scan the Tk source for more 
      Tcl_CreateExitHandler calls to make sure this is the only one, 
      and if so, just calling DeleteWindowsExitProc from 
      DLL_PROCESS_DETACH should succeed along with a 
      Tcl_DeleteExitHandler to remove it.  That's the easy fix.
      
      Will study this some more..  A very interesting problem.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  11. Ticket change [6286e7f311] (rid 92418) by davygrvy on 2003-12-13 04:11:53:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Note to Self:  Exit handlers can not be guarenteed to get 
      called from the same thread that created them.  Any 
      Tcl_ExitProc that accesses thread specific data are already 
      broken and should be using the ClientData to deref tsdPtr 
      instead.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. title changed to: "Win32: DllMain needs SEH around Tcl_Finalize()"
    5. username: "davygrvy"
  12. Ticket change [fc6619ebe5] (rid 108232) by davygrvy on 2003-12-13 06:47:06:

    1. icomment:
      
      
      File Added - 70389: patch.txt
      
      Logged In: YES 
      user_id=7549
      
      Attached a patch for Tk.  I'm still having problem in 
      DeleteWindowsExitProc(), but as it is now being called from 
      within an SEH block no damage occurs, yet am I just masking 
      it and being lazy?  I don't know yet.
      
      Added three new functions:
      TkCreateExitHandler
      TkDeleteExitHandler
      TkFinalize
      
      They're in the private Stubs table, which was a mistake, they 
      should be unstubbed, private, internal instead.  They just 
      apply a simple level of indirection so I can call TkFinalize from 
      the Tk's DllMain() for DLL_PROCESS_DETACH and avoid the 
      dangling pointer thing.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  13. Ticket change [88556a4192] (rid 131850) by davygrvy on 2003-12-13 07:56:28:

    1. icomment:
      
      
      File Deleted - 70389: 
      
      Logged In: YES 
      user_id=7549
      
      new Tk patch.  more better.  Where should the three new 
      funcs go?  I dropped them in generic/tkUtil.c, but 
      generic/tkEvent.c would mirror Tcl a bit better.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  14. Ticket change [aa943e2fe8] (rid 100949) by davygrvy on 2003-12-13 07:57:22:

    1. icomment:
      
      
      File Added - 70394: patch.txt
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  15. Ticket change [356a527cd8] (rid 106921) by davygrvy on 2003-12-22 04:28:37:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Mo, any comments on seh_dllmain_patch.txt?  I need to 
      commit it to the HEAD.  I can take out the gcc asm stuff if 
      it makes things easier for a later patch on top of this.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  16. Ticket change [9d0d3be34f] (rid 96246) by davygrvy on 2003-12-22 05:06:18:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      took out the HAVE_NO_SEH stuff and committed to the HEAD 
      so I can move this forward.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  17. Ticket change [24ee3f40f5] (rid 131195) by davygrvy on 2003-12-22 06:10:17:

    1. icomment:
      
      
      File Deleted - 70394: 
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  18. Ticket change [621069c0ac] (rid 92351) by davygrvy on 2003-12-22 06:11:04:

    1. icomment:
      
      
      File Added - 71220: patch.txt
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  19. Add attachment "patch.txt" [425451ceea] (rid 116350) by davygrvy on 2003-12-22 06:11:04.

  20. Ticket change [b41872bf84] (rid 124965) by davygrvy on 2003-12-22 06:50:23:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Committed Tk patch without MinGW assembly code.
      
      Problem for me is now solved and I can succesfully unload 
      both tcl and tk from within ExitProcess() all within an 
      exception handler.  Life is good.
      
      No mods where made to WishPanic.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  21. Ticket change [c99b6ef619] (rid 122317) by davygrvy on 2003-12-22 07:09:27:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      TODO: get MinGW custom SEH assembly into both Tcl and 
      Tk's DllMain()
      
      Merry XMas.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  22. Ticket change [c1d8ecf6ed] (rid 111391) by mdejong on 2003-12-26 11:17:26:

    1. icomment:
      Logged In: YES 
      user_id=90858
      
      Ho Ho Ho, the SEH ASM code changes have been committed
      to both Tcl and Tk on the HEAD.
      
      
    2. login: "mdejong"
    3. mimetype: "text/plain"
    4. username: "mdejong"
  23. Ticket change [e56593e9de] (rid 88121) by davygrvy on 2004-01-03 16:24:50:

    1. closedate changed to: "2004-01-03T09:24:50"
    2. closer changed to: "davygrvy"
    3. icomment:
      Logged In: YES 
      user_id=7549
      
      done, thank you.
      
      
    4. login: "davygrvy"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "davygrvy"