summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--generic/tclAssembly.c55
-rw-r--r--generic/tclIOSock.c9
-rw-r--r--generic/tclOOCall.c6
-rw-r--r--generic/tclOOInfo.c1
-rwxr-xr-xgeneric/tclStrToD.c8
-rw-r--r--tests/ooNext2.test25
7 files changed, 113 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 7e217ef..b55989c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2011-08-07 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tclOOInfo.c (InfoClassCallCmd): [Bug 3387082]: Plug memory
+ leak in call chain introspection.
+
+2011-08-06 Kevin B, Kenny <kennykb@acm.org>
+
+ * generic/tclAssemnbly.c: [Bug 3384840]: Plug another memory leak.
+ * generic/tclStrToD.c: [Bug 3386975]: Plug another memory leak.
+
+2011-08-05 Kevin B. Kenny <kennykb@acm.org>
+
+ * generic/tclStrToD.c: [Bug 3386975]: Plugged a memory leak in
+ double->string conversion.
+
2011-08-05 Don Porter <dgp@users.sourceforge.net>
*** 8.6b2 TAGGED FOR RELEASE ***
@@ -25,6 +40,12 @@
possible memory leak due to over-complex code for freeing the table of
labels.
+2011-08-04 Reinhard Max <max@suse.de>
+
+ * generic/tclIOSock.c (TclCreateSocketAddress): Don't bother using
+ AI_ADDRCONFIG for now, as it was causing problems in various
+ situations.
+
2011-08-04 Donal K. Fellows <dkf@users.sf.net>
* generic/tclAssembly.c (AssembleOneLine, GetBooleanOperand)
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index f45ae07..cd6dc38 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -783,11 +783,6 @@ TclNRAssembleObjCmd(
* Use NRE to evaluate the bytecode from the trampoline.
*/
-#if 0
- Tcl_NRAddCallback(interp, NRCallTEBC, INT2PTR(TCL_NR_BC_TYPE), codePtr,
- NULL, NULL);
- return TCL_OK;
-#endif
return TclNRExecuteByteCode(interp, codePtr);
}
@@ -817,11 +812,17 @@ CompileAssembleObj(
CompileEnv compEnv; /* Compilation environment structure */
register ByteCode *codePtr = NULL;
/* Bytecode resulting from the assembly */
+ register const AuxData * auxDataPtr;
+ /* Pointer to an auxiliary data element
+ * in a compilation environment being
+ * destroyed. */
Namespace* namespacePtr; /* Namespace in which variable and command
* names in the bytecode resolve */
int status; /* Status return from Tcl_AssembleCode */
const char* source; /* String representation of the source code */
int sourceLen; /* Length of the source code in bytes */
+ int i;
+
/*
* Get the expression ByteCode from the object. If it exists, make sure it
@@ -859,6 +860,43 @@ CompileAssembleObj(
* Assembly failed. Clean up and report the error.
*/
+ /*
+ * Free any literals that were constructed for the assembly.
+ */
+ for (i = 0; i < compEnv.literalArrayNext; i++) {
+ TclReleaseLiteral(interp, compEnv.literalArrayPtr[i].objPtr);
+ }
+
+ /*
+ * Free any auxiliary data that was attached to the bytecode
+ * under construction.
+ */
+
+ for (i = 0; i < compEnv.auxDataArrayNext; i++) {
+ auxDataPtr = compEnv.auxDataArrayPtr + i;
+ if (auxDataPtr->type->freeProc != NULL) {
+ (auxDataPtr->type->freeProc)(auxDataPtr->clientData);
+ }
+ }
+
+ /*
+ * TIP 280. If there is extended command line information,
+ * we need to clean it up.
+ */
+
+ if (compEnv.extCmdMapPtr != NULL) {
+ if (compEnv.extCmdMapPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(compEnv.extCmdMapPtr->path);
+ }
+ for (i = 0; i < compEnv.extCmdMapPtr->nuloc; ++i) {
+ ckfree(compEnv.extCmdMapPtr->loc[i].line);
+ }
+ if (compEnv.extCmdMapPtr->loc != NULL) {
+ ckfree(compEnv.extCmdMapPtr->loc);
+ }
+ Tcl_DeleteHashTable(&(compEnv.extCmdMapPtr->litInfo));
+ }
+
TclFreeCompileEnv(&compEnv);
return NULL;
}
@@ -3893,11 +3931,18 @@ BuildExceptionRanges(
prevPtr = bbPtr;
}
+ /* Make sure that all catches are closed */
+
if (catchDepth != 0) {
Tcl_Panic("unclosed catch at end of code in "
"tclAssembly.c:BuildExceptionRanges, can't happen");
}
+ /* Free temp storage */
+
+ ckfree(catchIndices);
+ ckfree(catches);
+
return TCL_OK;
}
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index aabd67d..768428f 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -178,6 +178,14 @@ TclCreateSocketAddress(
}
hints.ai_socktype = SOCK_STREAM;
+#if 0
+ /*
+ * We found some problems when using AI_ADDRCONFIG, e.g. on systems that
+ * have no networking besides the loopback interface and want to resolve
+ * localhost. See bugs 3385024, 3382419, 3382431. As the advantage of
+ * using AI_ADDRCONFIG in situations where it works, is probably low,
+ * we'll leave it out for now. After all, it is just an optimisation.
+ */
#if defined(AI_ADDRCONFIG) && !defined(_AIX) && !defined(__hpux)
/*
* Missing on: OpenBSD, NetBSD.
@@ -185,6 +193,7 @@ TclCreateSocketAddress(
*/
hints.ai_flags |= AI_ADDRCONFIG;
#endif
+#endif
if (willBind) {
hints.ai_flags |= AI_PASSIVE;
}
diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c
index b5d7c0c..9c9f3c0 100644
--- a/generic/tclOOCall.c
+++ b/generic/tclOOCall.c
@@ -1166,7 +1166,7 @@ TclOOGetStereotypeCallChain(
hPtr = NULL;
}
- callPtr = (CallChain *) ckalloc(sizeof(CallChain));
+ callPtr = ckalloc(sizeof(CallChain));
memset(callPtr, 0, sizeof(CallChain));
callPtr->flags = flags & (PUBLIC_METHOD|PRIVATE_METHOD|FILTER_HANDLING);
callPtr->epoch = fPtr->epoch;
@@ -1214,9 +1214,7 @@ TclOOGetStereotypeCallChain(
} else {
if (hPtr == NULL) {
if (clsPtr->classChainCache == NULL) {
- clsPtr->classChainCache = (Tcl_HashTable *)
- ckalloc(sizeof(Tcl_HashTable));
-
+ clsPtr->classChainCache = ckalloc(sizeof(Tcl_HashTable));
Tcl_InitObjHashTable(clsPtr->classChainCache);
}
hPtr = Tcl_CreateHashEntry(clsPtr->classChainCache,
diff --git a/generic/tclOOInfo.c b/generic/tclOOInfo.c
index ac8ae46..f298320 100644
--- a/generic/tclOOInfo.c
+++ b/generic/tclOOInfo.c
@@ -1542,6 +1542,7 @@ InfoClassCallCmd(
return TCL_ERROR;
}
Tcl_SetObjResult(interp, TclOORenderCallChain(interp, callPtr));
+ TclOODeleteChain(callPtr);
return TCL_OK;
}
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 8a961ff..a55ee83 100755
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -3875,6 +3875,7 @@ StrictBignumConversion(
* S = 2**s2 * 5*s5
*/
+ mp_init_multi(&temp, &dig, NULL);
TclBNInitBignumFromWideUInt(&b, bw);
mp_mul_2d(&b, b2, &b);
mp_init_set_int(&S, 1);
@@ -3889,13 +3890,11 @@ StrictBignumConversion(
ilim =ilim1;
--k;
}
- mp_init(&temp);
/*
* Convert the leading digit.
*/
- mp_init(&dig);
i = 0;
mp_div(&b, &S, &dig, &b);
if (dig.used > 1 || dig.dp[0] >= 10) {
@@ -3983,7 +3982,7 @@ StrictBignumConversion(
* string.
*/
- mp_clear_multi(&b, &temp, NULL);
+ mp_clear_multi(&b, &S, &temp, &dig, NULL);
*s = '\0';
*decpt = k;
if (endPtr) {
@@ -4480,6 +4479,9 @@ TclFinalizeDoubleConversion(void)
for (i=0; i<9; ++i) {
mp_clear(pow5 + i);
}
+ for (i=0; i < 5; ++i) {
+ mp_clear(pow5_13 + i);
+ }
}
/*
diff --git a/tests/ooNext2.test b/tests/ooNext2.test
index 51f02c5..eeade11 100644
--- a/tests/ooNext2.test
+++ b/tests/ooNext2.test
@@ -513,6 +513,21 @@ test oo-call-1.18 {object call introspection - memory leaks} -body {
info object call oo::object destroy
}
} -constraints memory -result 0
+test oo-call-1.19 {object call introspection - memory leaks} -setup {
+ oo::class create leaktester { method foo {} {dummy} }
+} -body {
+ leaktest {
+ set lt [leaktester new]
+ oo::objdefine $lt method foobar {} {dummy}
+ list [info object call $lt destroy] \
+ [info object call $lt foo] \
+ [info object call $lt bar] \
+ [info object call $lt foobar] \
+ [$lt destroy]
+ }
+} -cleanup {
+ leaktester destroy
+} -constraints memory -result 0
test oo-call-2.1 {class call introspection} -setup {
oo::class create root
@@ -684,6 +699,16 @@ test oo-call-2.13 {class call introspection - memory leaks} -body {
info class call oo::class destroy
}
} -constraints memory -result 0
+test oo-call-2.14 {class call introspection - memory leaks} -body {
+ leaktest {
+ oo::class create leaktester { method foo {} {dummy} }
+ [leaktester new] destroy
+ list [info class call leaktester destroy] \
+ [info class call leaktester foo] \
+ [info class call leaktester bar] \
+ [leaktester destroy]
+ }
+} -constraints memory -result 0
test oo-call-3.1 {current call introspection} -setup {
oo::class create root