summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2014-04-22 13:25:41 (GMT)
committersebres <sebres@users.sourceforge.net>2014-04-22 13:25:41 (GMT)
commit192fce9c01c4ee3827aa8f54967764c18bdd5dca (patch)
tree8c753402e4e14c2e9ce0d04c5bb6ef9ed65b565f /generic
parenta07adf4d6d28771d9aa74ef06526e5fb3035f5c1 (diff)
downloadtcl-192fce9c01c4ee3827aa8f54967764c18bdd5dca.zip
tcl-192fce9c01c4ee3827aa8f54967764c18bdd5dca.tar.gz
tcl-192fce9c01c4ee3827aa8f54967764c18bdd5dca.tar.bz2
Memory leak after thread exit, fixed (alloc cache released by exit), belong to ticket [3493120]
Moved over to branch bug-3493120. This is not ready for the core-8-5-branch. Segfaults all over the place in a thread-enabled build on a CentOS system.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInt.h1
-rw-r--r--generic/tclThread.c8
-rw-r--r--generic/tclThreadAlloc.c27
3 files changed, 34 insertions, 2 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1348340..00b246b 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2550,6 +2550,7 @@ MODULE_SCOPE void TclFinalizeObjects(void);
MODULE_SCOPE void TclFinalizePreserve(void);
MODULE_SCOPE void TclFinalizeSynchronization(void);
MODULE_SCOPE void TclFinalizeThreadAlloc(void);
+MODULE_SCOPE void TclFinalizeThreadAllocThread(void);
MODULE_SCOPE void TclFinalizeThreadData(void);
MODULE_SCOPE void TclFinalizeThreadObjects(void);
MODULE_SCOPE double TclFloor(mp_int *a);
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 8384107..d6b5bcb 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -338,8 +338,9 @@ Tcl_ConditionFinalize(
*
* TclFinalizeThreadData --
*
- * This function cleans up the thread-local storage. This is called once
- * for each thread.
+ * This function cleans up the thread-local storage. Secondary, it cleans
+ * thread alloc cache.
+ * This is called once for each thread before thread exits.
*
* Results:
* None.
@@ -354,6 +355,9 @@ void
TclFinalizeThreadData(void)
{
TclpFinalizeThreadDataThread();
+#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
+ TclFinalizeThreadAllocThread();
+#endif
}
/*
diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c
index 2e74fa7..106e908 100644
--- a/generic/tclThreadAlloc.c
+++ b/generic/tclThreadAlloc.c
@@ -1012,6 +1012,33 @@ TclFinalizeThreadAlloc(void)
TclpFreeAllocCache(NULL);
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclFinalizeThreadAllocThread --
+ *
+ * This procedure is used to destroy single thread private resources used
+ * in this file.
+ * Called in TclpFinalizeThreadData when a thread exits (Tcl_FinalizeThread).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclFinalizeThreadAllocThread(void)
+{
+ Cache *cachePtr = TclpGetAllocCache();
+ if (cachePtr != NULL) {
+ TclpFreeAllocCache(cachePtr);
+ }
+}
+
#else /* !(TCL_THREADS && USE_THREAD_ALLOC) */
/*
*----------------------------------------------------------------------