Tcl Source Code

Check-in [ccfd61a7cf]
Login

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

Overview
Comment:Delete associated data after running Tcl_InterpDeleteProc instead of before. Remove redundant/cyclic call to Tcl_DeleteAssocData.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-branch
Files: files | file ages | folders
SHA3-256: ccfd61a7cf6bce850d66e7f7435c6436288191fec63625982d264a41b262b282
User & Date: pooryorick 2021-05-15 19:04:09.191
Original Comment: When deleting an interp, delete associated data after running the corresponding Tcl_InterpDeleteProc instead of before to allow the Tcl_InterpDeleteProc to make use of the data.

In TcltestObj.c/VarPtrDeleteProc, remove call to Tcl_DeleteAssocData that is redundant and cylic.

References
2021-05-15
22:30 Ticket [28027d8bb7] Per-interp Loaded library structures not cleaned up on interp exit. status still Open with 4 other changes artifact: 2b81c100ce user: pooryorick
Context
2021-05-17
11:35
Merge 8.6 check-in: 3ee7e13727 user: jan.nijtmans tags: core-8-branch
2021-05-16
19:09
Break TclDeleteNamespaceChildren out of TclTeardownNamespace. Closed-Leaf check-in: a72e1e8016 user: pooryorick tags: pyk-namespace
2021-05-15
19:04
Delete associated data after running Tcl_InterpDeleteProc instead of before. Remove redundant/cycli... check-in: ccfd61a7cf user: pooryorick tags: core-8-branch
18:42
When deleting an interp, delete associated data after running the corresponding Tcl_InterpDeleteProc... check-in: 47892c9578 user: pooryorick tags: pyk-tclUnload
18:27
Add valgrind option --keep-deguginfo=yes check-in: c7502f772c user: pooryorick tags: core-8-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclBasic.c.
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838




1839
1840
1841
1842
1843
1844
1845
1846

1847
1848
1849
1850

1851
1852
1853
1854
1855
1856
1857
	for (; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
	    Tcl_DeleteCommandFromToken(interp, (Tcl_Command)Tcl_GetHashValue(hPtr));
	}
	Tcl_DeleteHashTable(hTablePtr);
	ckfree(hTablePtr);
    }

    /*
     * Invoke deletion callbacks; note that a callback can create new
     * callbacks, so we iterate.
     */

    while (iPtr->assocData != NULL) {
	AssocData *dPtr;

	hTablePtr = iPtr->assocData;
	iPtr->assocData = NULL;




	for (hPtr = Tcl_FirstHashEntry(hTablePtr, &search);
		hPtr != NULL;
		hPtr = Tcl_FirstHashEntry(hTablePtr, &search)) {
	    dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
	    Tcl_DeleteHashEntry(hPtr);
	    if (dPtr->proc != NULL) {
		dPtr->proc(dPtr->clientData, interp);
	    }

	    ckfree(dPtr);
	}
	Tcl_DeleteHashTable(hTablePtr);
	ckfree(hTablePtr);

    }

    /*
     * Pop the root frame pointer and finish deleting the global
     * namespace. The order is important [Bug 1658572].
     */








<
<
<
<

|



<
>
>
>
>




<



>




>







1822
1823
1824
1825
1826
1827
1828




1829
1830
1831
1832
1833

1834
1835
1836
1837
1838
1839
1840
1841

1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
	for (; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
	    Tcl_DeleteCommandFromToken(interp, (Tcl_Command)Tcl_GetHashValue(hPtr));
	}
	Tcl_DeleteHashTable(hTablePtr);
	ckfree(hTablePtr);
    }






    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);
	    ckfree(dPtr);
	}
	Tcl_DeleteHashTable(hTablePtr);
	ckfree(hTablePtr);
	iPtr->assocData = NULL;
    }

    /*
     * Pop the root frame pointer and finish deleting the global
     * namespace. The order is important [Bug 1658572].
     */

Changes to generic/tclTestObj.c.
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
static void VarPtrDeleteProc(void *clientData, Tcl_Interp *interp)
{
    int i;
    Tcl_Obj **varPtr = (Tcl_Obj **) clientData;
    for (i = 0;  i < NUMBER_OF_OBJECT_VARS;  i++) {
	if (varPtr[i]) Tcl_DecrRefCount(varPtr[i]);
    }
    Tcl_DeleteAssocData(interp, VARPTR_KEY);
    ckfree(varPtr);
}

static Tcl_Obj **GetVarPtr(Tcl_Interp *interp)
{
    Tcl_InterpDeleteProc *proc;








<







57
58
59
60
61
62
63

64
65
66
67
68
69
70
static void VarPtrDeleteProc(void *clientData, Tcl_Interp *interp)
{
    int i;
    Tcl_Obj **varPtr = (Tcl_Obj **) clientData;
    for (i = 0;  i < NUMBER_OF_OBJECT_VARS;  i++) {
	if (varPtr[i]) Tcl_DecrRefCount(varPtr[i]);
    }

    ckfree(varPtr);
}

static Tcl_Obj **GetVarPtr(Tcl_Interp *interp)
{
    Tcl_InterpDeleteProc *proc;