Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8118f309eaf631ace6eb1087cf99d9bfd2dab3ac
Ticket: 486399ffffffffffffffffffffffffffffffffff
Panic on exit before all threads returned
User & Date: ferrieux on 2009-05-07 03:27:28
Changes

  1. icomment:
    Here's a copy of a message I sent to tclcore regarding these issues:
    
    fromAlexandre Ferrieux <[email protected]>
    toTclCore <[email protected]>
    dateWed, May 6, 2009 at 12:42 AM
    subjectFinalization vs. Exit
    mailed-bygmail.com
    hide details 12:42 AM (21 hours ago)
    
    Reply
    
    Hi,
    
    As exhibited e.g. in
    https://sourceforge.net/tracker/?func=detail&aid=486399&group_id=10894&atid=110894
    , the Tcl finalization sequence is a complex thing.
    
    In this specific bug, the problem involves avoiding bad interaction of
    second-class threads with the main (first-class) one during the very
    last steps of teardown, when the ground starts to dissolve under
    everybody's feet.
    In other instances, it can be argued that we're doing way too much
    "administrative" cleanup (like freeing memory) just before exiting.
    
    Now a simple approach seems to be viable: make a clear distinction
    between the [exit] path and full finalization (eg in embedded
    scenarios, since Donal dislikes scenarii ;-).
    
    The idea, then, is to make clearer in the code the dichotomy between
    the exit handlers that are "administrative" (meaning they have no
    effect outside the dying process) and can thus be skipped in the
    [exit] case, and those that are really compulsory in all cases because
    they have side-effects on the outside world, these side-effects being
    part of a documented or implicit contract that we simply cannot break.
    Then, for the [exit] path, just do the compulsory ones, and call the
    OS's exit() function.
    
    Question: could you help me draw this dichotomy ?
    
    Here is what I have spotted so far:
    
      - process-wide exit handlers registered with Tcl_CreateExitHandler,
    aka "early exit handlers" --> compulsory
    
      - per-thread exit handlers (freeing memory) --> skippable for [exit]
    
    Still in the gray zone, is FinalizeIOSubsystem. I know of cases where
    not calling it might have long-ranging effects (like RST sent on all
    non-closed sockets), but since it deals with per-thread/interp
    structures (like channel lists), it should either be entirely skipped
    or done for all threads... which is problematic at exit time if some
    threads are blocked or in an uncontrolled state.
    
    Thanks in advance for any insight on this,
    
    -Alex
    
    
  2. login: "ferrieux"
  3. mimetype: "text/plain"
  4. username: "ferrieux"