Tcl Source Code

Check-in [eb11820a8e]
Login

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

Overview
Comment:3392070 More complete prevention of Tcl_Obj reference cycles when producing an intrep of ByteCode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3392070
Files: files | file ages | folders
SHA1: eb11820a8e2ddb651d435dacd4088f03647ec2ea
User & Date: dgp 2011-08-16 19:49:57
Original Comment: 3392070 More complete prevention of Tcl_Obj reference cycles when producing an intrep of ByteCode.
Context
2011-08-17
12:19
3392070 More complete prevention of Tcl_Obj reference cycles when producing an intrep of ByteCode. check-in: ed21e85c21 user: dgp tags: trunk
12:15
3392070 More complete prevention of Tcl_Obj reference cycles when producing an intrep of ByteCode. Closed-Leaf check-in: 9eeb666324 user: dgp tags: mistake
2011-08-16
19:49
3392070 More complete prevention of Tcl_Obj reference cycles when producing an intrep of ByteCode. Closed-Leaf check-in: eb11820a8e user: dgp tags: bug-3392070
13:55
Small changes to quell gcc warnings and make message generation less ugly. check-in: df6fb9a914 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2011-08-16  Donal K. Fellows  <[email protected]>

	* generic/tclListObj.c (TclLindexList, TclLsetFlat): Silence warnings
	about (unreachable) cases of uninitialized variables.
	* generic/tclCmdIL.c (SelectObjFromSublist): Improve the generation of
	* generic/tclIndexObj.c (Tcl_ParseArgsObjv): messages through the use
	* generic/tclVar.c (ArrayStartSearchCmd):    of Tcl_ObjPrintf.
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2011-08-16  Don Porter  <[email protected]>

	* generic/tclCompile.c: [Bug 3392070] More complete prevention of
	Tcl_Obj reference cycles when producing an intrep of ByteCode.

2011-08-16  Donal K. Fellows  <[email protected]>

	* generic/tclListObj.c (TclLindexList, TclLsetFlat): Silence warnings
	about (unreachable) cases of uninitialized variables.
	* generic/tclCmdIL.c (SelectObjFromSublist): Improve the generation of
	* generic/tclIndexObj.c (Tcl_ParseArgsObjv): messages through the use
	* generic/tclVar.c (ArrayStartSearchCmd):    of Tcl_ObjPrintf.

Changes to generic/tclCompile.c.

2445
2446
2447
2448
2449
2450
2451





2452



2453
2454
2455
2456
2457
2458
2459
2460
    for (i = 0;  i < numLitObjects;  i++) {
	if (objPtr == envPtr->literalArrayPtr[i].objPtr) {
	    /*
	     * Prevent circular reference where the bytecode intrep of
	     * a value contains a literal which is that same value.
	     * If this is allowed to happen, refcount decrements may not
	     * reach zero, and memory may leak.  Bugs 467523, 3357771





	     */



	    codePtr->objArrayPtr[i] = Tcl_DuplicateObj(objPtr);
	    Tcl_IncrRefCount(codePtr->objArrayPtr[i]);
	    Tcl_DecrRefCount(objPtr);
	} else {
	    codePtr->objArrayPtr[i] = envPtr->literalArrayPtr[i].objPtr;
	}
    }








>
>
>
>
>

>
>
>
|







2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
    for (i = 0;  i < numLitObjects;  i++) {
	if (objPtr == envPtr->literalArrayPtr[i].objPtr) {
	    /*
	     * Prevent circular reference where the bytecode intrep of
	     * a value contains a literal which is that same value.
	     * If this is allowed to happen, refcount decrements may not
	     * reach zero, and memory may leak.  Bugs 467523, 3357771
	     *
	     * NOTE:  [Bugs 3392070, 3389764] We make a copy based completely
	     * on the string value, and do not call Tcl_DuplicateObj() so we
             * can be sure we do not have any lingering cycles hiding in
	     * the intrep.
	     */
	    int numBytes;
	    const char *bytes = Tcl_GetStringFromObj(objPtr, &numBytes);

	    codePtr->objArrayPtr[i] = Tcl_NewStringObj(bytes, numBytes);
	    Tcl_IncrRefCount(codePtr->objArrayPtr[i]);
	    Tcl_DecrRefCount(objPtr);
	} else {
	    codePtr->objArrayPtr[i] = envPtr->literalArrayPtr[i].objPtr;
	}
    }