#1899: Memory leak in compilers/imcc/main.c
------------------------+---------------------------------------------------
Reporter: bluescreen | Owner: bluescreen
Type: bug | Status: assigned
Priority: normal | Milestone:
Component: imcc | Version: master
Severity: medium | Keywords:
Lang: | Patch:
Platform: |
------------------------+---------------------------------------------------
Description changed by bluescreen:
Old description:
> Around line 567, [[BR]]
> [[BR]]
> if (IMCC_INFO(interp)->error_code) {[[BR]]
> char * const error_str = Parrot_str_to_cstring(interp,
> IMCC_INFO(interp)->error_message);[[BR]]
>
> IMCC_INFO(interp)->error_code=IMCC_FATAL_EXCEPTION;[[BR]]
> fprintf(stderr, "error:imcc:%s", error_str);[[BR]]
> IMCC_print_inc(interp);[[BR]]
> Parrot_str_free_cstring(error_str);[[BR]]
> Parrot_x_exit(interp, IMCC_FATAL_EXCEPTION);[[BR]]
> }[[BR]]
> imc_cleanup(interp, yyscanner);[[BR]]
> [[BR]]
> In the error branch main.c is not calling imc_cleanup so valgrind gives
> the following output:[[BR]]
>
> ==4322== 222 (208 direct, 14 indirect) bytes in 1 blocks are definitely
> lost in loss record 238 of 508[[BR]]
>
> ==4322== at 0x4C27480: calloc (vg_replace_malloc.c:467)[[BR]]
>
> ==4322== by 0x4FB05F7: gc_ms2_allocate_memory_chunk_zeroed
> (gc_ms2.c:1410)[[BR]]
>
> ==4322== by 0x4FA9EC5:
> Parrot_gc_allocate_memory_chunk_with_interior_pointers (api.c:628)[[BR]]
>
> ==4322== by 0x50FEE0C: new_frame (imcc.l:752)[[BR]]
>
> ==4322== by 0x5100397: IMCC_push_parser_state (imcc.l:1263)[[BR]]
>
> ==4322== by 0x5102552: compile_to_bytecode (main.c:556)[[BR]]
>
> ==4322== by 0x51029C4: imcc_run (main.c:652)[[BR]]
>
> ==4322== by 0x401313: main (main.c:152)[[BR]]
New description:
Around line 567,
{{{
if (IMCC_INFO(interp)->error_code) {[[BR]]
char * const error_str = Parrot_str_to_cstring(interp,
IMCC_INFO(interp)->error_message);
IMCC_INFO(interp)->error_code=IMCC_FATAL_EXCEPTION;
fprintf(stderr, "error:imcc:%s", error_str);
IMCC_print_inc(interp);[[BR]]
Parrot_str_free_cstring(error_str);
Parrot_x_exit(interp, IMCC_FATAL_EXCEPTION);
}
imc_cleanup(interp, yyscanner);
}}}
In the error branch main.c is not calling imc_cleanup so valgrind gives
the following output:[[BR]]
{{{
==4322== 222 (208 direct, 14 indirect) bytes in 1 blocks are definitely
lost in loss record 238 of 508
==4322== at 0x4C27480: calloc (vg_replace_malloc.c:467)
==4322== by 0x4FB05F7: gc_ms2_allocate_memory_chunk_zeroed
(gc_ms2.c:1410)
==4322== by 0x4FA9EC5:
Parrot_gc_allocate_memory_chunk_with_interior_pointers (api.c:628)
==4322== by 0x50FEE0C: new_frame (imcc.l:752)
==4322== by 0x5100397: IMCC_push_parser_state (imcc.l:1263)
==4322== by 0x5102552: compile_to_bytecode (main.c:556)
==4322== by 0x51029C4: imcc_run (main.c:652)
==4322== by 0x401313: main (main.c:152)
}}}}
--
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/1899#comment:3>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets