Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-27
21:24 • Pending ticket [2577420fff]: Tcl_GetInterpPath produces invalid path. plus 5... artifact: f59237d845 user: jan.nijtmans
21:24
Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory check-in: b428759224 user: jan.nijtmans tags: trunk, main
19:21 • Ticket [2577420fff] Tcl_GetInterpPath produces invalid path. status still Op... artifact: 2a7c5a9a24 user: serhiy.storchaka
15:15 • Ticket [2577420fff]: 7 changes artifact: f51784e791 user: jan.nijtmans
13:20
Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory check-in: 0a9c575129 user: jan.nijtmans tags: trunk, main
2026-10-17
08:39 • Ticket [2577420fff] Tcl_GetInterpPath produces invalid path. status still Op... artifact: a65c5de9da user: serhiy.storchaka
08:38
Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory in a Tcl_CallWhenDeleted... check-in: 49e00a9cd6 user: serhiy.storchaka tags: interp-delete-callbacks-path
2009-03-17
15:06 • Ticket [2577420fff] Tcl_GetInterpPath produces invalid path. status still Op... artifact: e00998dbd8 user: mistachkin
15:01 • Ticket [2577420fff]: 4 changes artifact: 791ccb2aeb user: mistachkin
2009-02-07
14:54 • New ticket [2577420fff]. artifact: a9c63dd97f user: sbron

Tcl_GetInterpPath produces invalid path.

Pending2577420fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 5 days ago
Descriptionplain2009-02-07 14:54:54
Tcl_GetInterpPath returns TCL_OK when called form within a Tcl_InterpDeleteProc that runs when the slave interp is deleted, but the path it produces is garbage.

The following code prints some strange character when it is registered with Tcl_CallWhenDeleted for some slave interpreter and that interpreter is subsequently deleted.

void InterpDelete(ClientData dummy, Tcl_Interp *interp)
{
   Tcl_Interp *master;
   master = Tcl_GetMaster(interp);
   if (master != NULL) {
      Tcl_GetInterpPath(master, interp);
      printf("Path: %s\n", Tcl_GetStringResult(master));
   }
}

Either the function should produce the correct path, or it should return TCL_ERROR. In the latter case it would also be helpful if the manual page would mention that this function cannot be used when the interp is in the process of being deleted.

Problem was found on SuSE linux 11.0.
Referenced by3
  • b428759224Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory check-in2026-11-27 21:24:03
  • 0a9c575129Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory check-in2026-11-27 13:20:42
  • 49e00a9cd6Fix [2577420fff]: Tcl_GetInterpPath() and Tcl_GetParent() used freed memory in a Tcl_CallWhenDeleted() callback of a child interpreter. Unlink the child from its parent only after Tcl_DeleteInterp(), and free the InterpInfo after all delete callbacks. check-in2026-10-17 08:38:42
mistachkinplain2009-03-17 15:01:54
This bug may be related to 1502071.
mistachkinplain2009-03-17 15:06:52
This bug may be related to 1502071.
serhiy.storchakawiki2026-10-17 08:39:47

Still a use-after-free in 9.0 and 9.1 (ASan): the child's entry in the parent's child table is removed before the child's Tcl_CallWhenDeleted() callbacks run, and the InterpInfo may be freed before them too, because it is freed by another delete callback. 8.6 and 9.0 print the right path only because the freed memory still holds it. Proposed fix in branch interp-delete-callbacks-path: unlink after Tcl_DeleteInterp(), and free the InterpInfo after all delete callbacks. No test, since no script command can register such a callback.

jan.nijtmanswiki2026-11-27 15:15:32

I'm seeing (both on Windows and Linux:

rename.test
Test file error: child killed: segmentation violation

So, something is wrong with this patch.

serhiy.storchakawiki2026-11-27 19:21:56

The rename.test segfault came from the branch: a child being deleted could still be deleted again by name. Fixed in [2a2b5c0667] on interp-delete-callbacks-path.

jan.nijtmanswiki2026-11-27 21:24:58

Now merged to [trunk]

Many thanks!

Log in (anonymous is fine) to add a comment.