Tcl Source Code

Check-in [fb7e419d42]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Failed to mutex protect all multi-thread access to the hash tables in the [tcl::process] implementation. This was causing segfaults in thread-8.1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: fb7e419d4273820631de4ded40353989d5530c1aea5e7f6c78cb7af97fc0e980
User & Date: dgp 2018-04-05 13:34:58
Context
2018-04-05
15:37
[string cat] was failing to NUL terminate string reps. Stopped "string" values triggering false valg... check-in: 6360678926 user: dgp tags: core-8-branch
13:36
merge 8.7 check-in: 4711766df3 user: dgp tags: trunk
13:34
Failed to mutex protect all multi-thread access to the hash tables in the [tcl::process] implementat... check-in: fb7e419d42 user: dgp tags: core-8-branch
2018-03-30
19:22
Refactor the [lrange] machinery into a single routine TclListObjRange(). Apply some optimizations. C... check-in: 0f8ef41b28 user: dgp tags: core-8-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclProcess.c.

883
884
885
886
887
888
889

890
891
892
893
894
895
896
897
898
899

900
901
902
903
904
905
906
907
908

909
910
911
912
913
914
915
916
917

918
919
920
921
922
923
924
...
944
945
946
947
948
949
950

951
952
    ProcessInfo *info;
    TclProcessWaitStatus result;

    /*
     * First search for pid in table.
     */


    entry = Tcl_FindHashEntry(&infoTablePerPid, pid);
    if (!entry) {
	/*
	 * Unknown process, just call WaitProcessStatus and return.
	 */
	
	result = WaitProcessStatus(pid, TclpGetPid(pid), options, codePtr, 
		msgObjPtr, errorObjPtr);
	if (msgObjPtr && *msgObjPtr) Tcl_IncrRefCount(*msgObjPtr);
	if (errorObjPtr && *errorObjPtr) Tcl_IncrRefCount(*errorObjPtr);

	return result;
    }

    info = (ProcessInfo *) Tcl_GetHashValue(entry);
    if (info->purge) {
	/*
	 * Process has completed but TclProcessWait has already been called,
	 * so report no change.
	 */

	
	return TCL_PROCESS_UNCHANGED;
    }

    RefreshProcessInfo(info, options);
    if (info->status == TCL_PROCESS_UNCHANGED) {
	/*
	 * No change, stop there.
	 */

	
	return TCL_PROCESS_UNCHANGED;
    }

    /*
     * Set return values.
     */
................................................................................
	/*
	 * Eventually purge. Subsequent calls will return
	 * TCL_PROCESS_UNCHANGED.
	 */

	info->purge = 1;
    }

    return result;
}






>










>









>









>







 







>


883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
...
948
949
950
951
952
953
954
955
956
957
    ProcessInfo *info;
    TclProcessWaitStatus result;

    /*
     * First search for pid in table.
     */

    Tcl_MutexLock(&infoTablesMutex);
    entry = Tcl_FindHashEntry(&infoTablePerPid, pid);
    if (!entry) {
	/*
	 * Unknown process, just call WaitProcessStatus and return.
	 */
	
	result = WaitProcessStatus(pid, TclpGetPid(pid), options, codePtr, 
		msgObjPtr, errorObjPtr);
	if (msgObjPtr && *msgObjPtr) Tcl_IncrRefCount(*msgObjPtr);
	if (errorObjPtr && *errorObjPtr) Tcl_IncrRefCount(*errorObjPtr);
    Tcl_MutexUnlock(&infoTablesMutex);
	return result;
    }

    info = (ProcessInfo *) Tcl_GetHashValue(entry);
    if (info->purge) {
	/*
	 * Process has completed but TclProcessWait has already been called,
	 * so report no change.
	 */
    Tcl_MutexUnlock(&infoTablesMutex);
	
	return TCL_PROCESS_UNCHANGED;
    }

    RefreshProcessInfo(info, options);
    if (info->status == TCL_PROCESS_UNCHANGED) {
	/*
	 * No change, stop there.
	 */
    Tcl_MutexUnlock(&infoTablesMutex);
	
	return TCL_PROCESS_UNCHANGED;
    }

    /*
     * Set return values.
     */
................................................................................
	/*
	 * Eventually purge. Subsequent calls will return
	 * TCL_PROCESS_UNCHANGED.
	 */

	info->purge = 1;
    }
    Tcl_MutexUnlock(&infoTablesMutex);
    return result;
}