Skip to content

Commit b85082a

Browse files
committed
fixes segfault [d4ba38d00d06ebba]: only main interpreter used as default thread interpreter (stored in its TSD)
1 parent 5a65e5e commit b85082a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

generic/threadCmd.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,17 @@ Init(
583583
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
584584

585585
if (tsdPtr->interp == NULL) {
586+
Tcl_Interp *tmpInterp, *mainInterp = interp;
586587
memset(tsdPtr, 0, sizeof(ThreadSpecificData));
587-
tsdPtr->interp = interp;
588+
/*
589+
* Retrieve main interpreter of the thread, only
590+
* main interpreter used as default thread-interpreter,
591+
* so no childs here, see bug [d4ba38d00d06ebba]
592+
*/
593+
while (mainInterp && (tmpInterp = Tcl_GetMaster(mainInterp))) {
594+
mainInterp = tmpInterp;
595+
}
596+
tsdPtr->interp = mainInterp;
588597
ListUpdate(tsdPtr);
589598
Tcl_CreateThreadExitHandler(ThreadExitProc,
590599
threadEmptyResult);

0 commit comments

Comments
 (0)