Menu

#51 tclblend - potential memory leak

open
nobody
None
5
2009-09-25
2009-09-25
Tony B
No

If SetJavaCmdFromAny (javaObj.c) is invoked for a command referencing a java object then the Tcl_Obj's typePtr is set to null before calling SetCmdNameFromAny which prevents it calling the Tcl_Obj 's freeIntRepProc and thus deleting the the java object. However a "commandname" Tcl_Obj will already have its internalRep.twoPtrValue.ptr1 set to a malloc'ed ResolvedCmdName structure, which is not released before being set to a new malloc'ed ResolvedCmdName structure. This happens when Tcl_GetCommandFromObj() forces another conversion due to change in namespace

tclBlend 1.4.1
tcl8.4.19
Itcl3.4
Java 1.4/1.5/6
solaris 10, hpux 11, redhat 3/4/5

Discussion

  • Tony B

    Tony B - 2010-02-05

    example to demonstrate bug

     
  • Tony B

    Tony B - 2010-02-05

    Uploaded memtest.tcl to demonstrate the bug.

    Run the script and it prompts for input "A" or "B".

    Enter A and monitor process for 10 - 20 seconds. This test creates java objects in namespace A and executes the resulting commands also in namespace A. Process size inreases and then remains constant.

    Re-run and enter B, This test creates java objects in namespace A and executes and executes the resulting commands in namespace B. Monitoring the process show its size continually increasing.

    Process needs to be manually terminated

     
  • Mo DeJong

    Mo DeJong - 2010-04-06

    Minimal test case:

    namespace eval B {
    proc run {obj} {
    # if variable is treated as a command in this namespace the
    # ResolvedCmdName is regenerated, but the previous is not released.
    $obj toString
    }
    }

    set obj [java::new String "foo"]
    $obj toString
    B::run $obj
    set obj ""

     
  • Mo DeJong

    Mo DeJong - 2010-04-06

    Created Patch 2982514

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.