Skip to content

Memory leaks in nested procedures #252

@tueda

Description

@tueda

The first bug of #250 can be reproduced by

#procedure foo()
  #procedure bar()
  #endprocedure
#endprocedure

#call foo()
#call foo()
.end

Then valgrind --leak-check=full vorm test.frm gives

==25298== Memcheck, a memory error detector
==25298== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25298== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==25298== Command: vorm test.frm
==25298==
FORM 4.2.0 (Dec 13 2017, v4.2.0-28-g4493f01) 64-bits  Run: Wed Dec 13 18:25:58 2017
    #procedure foo()
      #procedure bar()
      #endprocedure
    #endprocedure

    #call foo()
    #call foo()
    .end
  0.02 sec out of 0.02 sec
==25298==
==25298== HEAP SUMMARY:
==25298==     in use at exit: 387,475,840 bytes in 125 blocks
==25298==   total heap usage: 646 allocs, 521 frees, 387,529,621 bytes allocated
==25298==
==25298== 8 bytes in 1 blocks are definitely lost in loss record 9 of 120
==25298==    at 0x4C2AB96: malloc (vg_replace_malloc.c:299)
==25298==    by 0x4FFA16: Malloc1 (tools.c:2230)
==25298==    by 0x4FFA5A: strDup1 (tools.c:1816)
==25298==    by 0x4AC6D5: DoProcedure (pre.c:3880)
==25298==    by 0x4AF3D2: PreProInstruction (pre.c:1156)
==25298==    by 0x4AFF3A: PreProcessor (pre.c:931)
==25298==    by 0x4E8F2D: main (startup.c:1607)
==25298==
==25298== 136 bytes in 1 blocks are definitely lost in loss record 59 of 120
==25298==    at 0x4C2AB96: malloc (vg_replace_malloc.c:299)
==25298==    by 0x4FFA16: Malloc1 (tools.c:2230)
==25298==    by 0x4AC0FD: PreLoad (pre.c:4132)
==25298==    by 0x4AC64A: DoProcedure (pre.c:3867)
==25298==    by 0x4AF3D2: PreProInstruction (pre.c:1156)
==25298==    by 0x4AFF3A: PreProcessor (pre.c:931)
==25298==    by 0x4E8F2D: main (startup.c:1607)
==25298==
==25298== LEAK SUMMARY:
==25298==    definitely lost: 144 bytes in 2 blocks
==25298==    indirectly lost: 0 bytes in 0 blocks
==25298==      possibly lost: 0 bytes in 0 blocks
==25298==    still reachable: 387,475,696 bytes in 123 blocks
==25298==         suppressed: 0 bytes in 0 blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions