diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2008-08-11 20:13:38 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2008-08-11 20:13:38 (GMT) |
commit | d1f1796ca325690bfd9b04eab533fb91ada2eb10 (patch) | |
tree | fee0c8028045472b91b463fd042c94c3f0f82611 /tests | |
parent | 5e2cb2ac1c4a247cc05a95d468166382062e1f95 (diff) | |
download | tcl-d1f1796ca325690bfd9b04eab533fb91ada2eb10.zip tcl-d1f1796ca325690bfd9b04eab533fb91ada2eb10.tar.gz tcl-d1f1796ca325690bfd9b04eab533fb91ada2eb10.tar.bz2 |
* generic/tclProc.c (Tcl_ProcObjCmd): Fixed memory leak triggered
* tests/proc.test: by procbody::test::proc. See [Bug 2043636].
Added a test case demonstrating the leak before the fix. Fixed a
few spelling errors in test descriptions as well.
FossilOrigin-Name: 9722d89856b06bc1f17dca759cb8ee07907b90ce
Diffstat (limited to 'tests')
-rw-r--r-- | tests/proc.test | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/tests/proc.test b/tests/proc.test index 222a31f..8a9ec14 100644 --- a/tests/proc.test +++ b/tests/proc.test @@ -13,13 +13,15 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: proc.test,v 1.11.2.1 2004/05/02 21:07:16 msofer Exp $ +# RCS: @(#) $Id: proc.test,v 1.11.2.2 2008/08/11 20:13:44 andreas_kupries Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import -force ::tcltest::* } +testConstraint memory [llength [info commands memory]] + catch {eval namespace delete [namespace children :: test_ns_*]} catch {rename p ""} catch {rename {} ""} @@ -237,7 +239,7 @@ test proc-4.3 {TclCreateProc, procbody obj, too many args} { set result } {procedure "t": arg list contains 3 entries, precompiled header expects 1} -test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} { +test proc-4.4 {TclCreateProc, procbody obj, inconsistent arg name} { catch { proc p {x y z} { set v [join [list $x $y $z]] @@ -254,7 +256,7 @@ test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} { set result } {procedure "t": formal parameter 1 is inconsistent with precompiled body} -test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} { +test proc-4.5 {TclCreateProc, procbody obj, inconsistent arg default type} { catch { proc p {x y {z Z}} { set v [join [list $x $y $z]] @@ -271,7 +273,7 @@ test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} { set result } {procedure "t": formal parameter 2 is inconsistent with precompiled body} -test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} { +test proc-4.6 {TclCreateProc, procbody obj, inconsistent arg default type} { catch { proc p {x y z} { set v [join [list $x $y $z]] @@ -288,7 +290,7 @@ test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} { set result } {procedure "t": formal parameter 2 is inconsistent with precompiled body} -test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} { +test proc-4.7 {TclCreateProc, procbody obj, inconsistent arg default value} { catch { proc p {x y {z Z}} { set v [join [list $x $y $z]] @@ -305,6 +307,30 @@ test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} { set result } {procedure "t": formal parameter "z" has default value inconsistent with precompiled body} +test proc-4.8 {TclCreateProc, procbody obj, no leak on multiple iterations} -setup { + proc getbytes {} { + set lines [split [memory info] "\n"] + lindex $lines 3 3 + } + proc px x { + set y [string tolower $x] + return "$x:$y" + } + px x +} -constraints memory -body { + set end [getbytes] + for {set i 0} {$i < 5} {incr i} { + + procbodytest::proc tx x px + + set tmp $end + set end [getbytes] + } + set leakedBytes [expr {$end - $tmp}] +} -cleanup { + rename getbytes {} +} -result 0 + test proc-5.1 {Bytecompiling noop; test for correct argument substitution} { proc p args {} ; # this will be bytecompiled into t proc t {} { |