Skip to content

Memory leak when clan_scop_extract fails #20

@bondhugula

Description

@bondhugula

With commit: 379eead

When clan_scop_extract fails here (i.e., the return scop is NULL or scop->statement is NULL), I see a memory leak. Here's the trace from valgrind:

==7501== 136 (128 direct, 8 indirect) bytes in 4 blocks are definitely lost in loss record 44 of 52
==7501== at 0x483880B: malloc (vg_replace_malloc.c:309)
==7501== by 0x482A1D: clan_symbol_malloc (symbol.c:198)
==7501== by 0x482EDF: clan_symbol_clone_one (symbol.c:514)
==7501== by 0x483081: clan_symbol_new_iterator (symbol.c:596)
==7501== by 0x47E461: yyparse (parser.y:627)
==7501== by 0x4801F4: clan_parse (parser.y:2430)
==7501== by 0x40C16E: main (main.c:553)

To reproduce:

libtool --mode=execute valgrind --leak-check=full clan/clan test/heat-2d.c

[Clan] Info: parsing file #1 (test/heat-3d.c)
[Clan] Error: syntax error at line 91, column 21.
A[(t + 1) % 2][i][j][k] =
~~~^

NULL scop

==10699==
==10699== HEAP SUMMARY:
==10699== in use at exit: 44,996 bytes in 27 blocks
==10699== total heap usage: 835 allocs, 808 frees, 532,303 bytes allocated
==10699==
==10699== 136 (128 direct, 8 indirect) bytes in 4 blocks are definitely lost in loss record 5 of 8
==10699== at 0x483880B: malloc (vg_replace_malloc.c:309)
==10699== by 0x48554CD: clan_symbol_malloc (symbol.c:198)
==10699== by 0x485591F: clan_symbol_clone_one (symbol.c:514)
==10699== by 0x4855AE1: clan_symbol_new_iterator (symbol.c:596)
==10699== by 0x484FD26: yyparse (parser.y:627)
==10699== by 0x4851C5E: clan_parse (parser.y:2430)
==10699== by 0x401236: main (clan.c:85)
==10699==
==10699== LEAK SUMMARY:
==10699== definitely lost: 128 bytes in 4 blocks
==10699== indirectly lost: 8 bytes in 4 blocks
==10699== possibly lost: 0 bytes in 0 blocks
==10699== still reachable: 44,860 bytes in 19 blocks
==10699== suppressed: 0 bytes in 0 blocks
==10699== Reachable blocks (those to which a pointer was found) are not shown.
==10699== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==10699==
==10699== For counts of detected and suppressed errors, rerun with: -v
==10699== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

where test/heat-2d.c can be found at https://github.com/bondhugula/pluto

I've been able to reproduce this on other test cases that fail scop extraction this way - so it's not particular to this test case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions