Skip to content
Tcl Source Code History Of Ticket 34870ab5756911d1
Login

History Of Ticket 34870ab5756911d1

Artifacts Associated With Ticket 34870ab5756911d1

  1. Ticket change [9411eca5c4] (rid 227024) by chpock on 2024-05-30 16:41:27:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      tcl9.0 first call assocdata deletion callbacks, then release each data from hash after the callback, and then set iPtr->assocData to NULL when all assocdata is removed: [https://github.com/tcltk/tcl/blob/db5ec326417727be7fdfcfe92d15193c7d886648/generic/tclBasic.c#L1982-L1990](https://github.com/tcltk/tcl/blob/db5ec326417727be7fdfcfe92d15193c7d886648/generic/tclBasic.c#L1982-L1990)
      
      ```
      if (iPtr->assocData != NULL) {
      	AssocData *dPtr;
      
      	hTablePtr = iPtr->assocData;
      	/*
      	 * Invoke deletion callbacks; note that a callback can create new
      	 * callbacks, so we iterate.
      	 */
      	for (hPtr = Tcl_FirstHashEntry(hTablePtr, &search);
      		hPtr != NULL;
      		hPtr = Tcl_FirstHashEntry(hTablePtr, &search)) {
      	    dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
      	    if (dPtr->proc != NULL) {
      		dPtr->proc(dPtr->clientData, interp);
      	    }
      	    Tcl_DeleteHashEntry(hPtr);
      	    Tcl_Free(dPtr);
      	}
      	Tcl_DeleteHashTable(hTablePtr);
      	Tcl_Free(hTablePtr);
      	iPtr->assocData = NULL;
          }
      ```
      
      In tcl8.6.14 the behavior was different: it first set iPtr->assocData to NULL, then for each assocData it removes hash entry, and after that invokes callback: [https://github.com/tcltk/tcl/blob/1d84e70c2decaf650f0f1a41b3de81bb0e19b58e/generic/tclBasic.c#L1539-L1550](https://github.com/tcltk/tcl/blob/1d84e70c2decaf650f0f1a41b3de81bb0e19b58e/generic/tclBasic.c#L1539-L1550)
      
      The difference in behavior leads to crash if assocdata deletion callback invokes  Tcl_DeleteAssocData(). Tcl9 tries to call the callback, callback releases assocdata hash entry, then DeleteInterpProc() continues and releases the hash entry again.
      
      I don't see in documentation, that assocdata deletion callback must not call Tcl_DeleteAssocData(). Also, at least tclvfs is affected by this case: [https://github.com/chpock/tclvfs/blob/289dfa5ebf0c7374737c7a1fdef7103a0100b303/generic/vfs.c#L434](https://github.com/chpock/tclvfs/blob/289dfa5ebf0c7374737c7a1fdef7103a0100b303/generic/vfs.c#L434)
      
    5. foundin initialized to: "9.0b2"
    6. is_private initialized to: "0"
    7. login: "chpock"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "fb0bef387a3d333f7502b23b2ca5bd198a1d1f87"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "chpock"
    14. subsystem initialized to: "20. [interp]"
    15. title initialized to: "Double free of assocdata entry"
    16. type initialized to: "Bug"
  2. Ticket change [e547fdaa94] (rid 227025) by sebres on 2024-05-30 18:32:51:

    1. foundin changed to: "8.7+"
    2. icomment:
      Although I don't think it is good idea to invoke Tcl_DeleteAssocData from deletion callback (just an unneeded hash search), it looks indeed like an oversight:
      
      the issue going to [b95643fa3926f2e3] fixing loss of line (probably by conflict resolving) in [ec7e558c34856b07]. So it's safe to restore it back.
      
      <i>Again, a next illustration why a certain hygiene by space/spelling/line-length/whatever "fixing" is important and what pure artificial "fix" may cause in the long term. (I don't stop to repeat it.)</i>
      
      It affects 8.7 in the same way. I'll fix it now for 8.7+.
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
  3. Ticket change [4836fab667] (rid 227028) by sebres on 2024-05-30 18:39:33:

    1. closedate changed to: "2460461.27746551"
    2. closer changed to: "sebres"
    3. icomment:
      Fixed in [0aedd271b215a880] and merged to 9.0.
      
      Thx for the report.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  4. Ticket change [ae00ea5aec] (rid 228653) by sebres on 2024-07-15 01:37:29:

    1. closedate changed to: "2460506.56770734"
    2. icomment:
      The fix for that has a side effect detected in load library module (caused a memory leak, see [ae09f6b190ceec31]) due to improper free of assoc data in its clean-up proc. Moreover it looks like the full rewrite of LoadCleanupProc in 8.7+ (as well as UnloadLibrary) was previously implemented incorrectly for the case of interpreter deletion.<br/>
      Ultimately fixed in [24ace090aad63399].
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"