Ticket #1899 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Memory leak in compilers/imcc/main.c

Reported by: bluescreen Owned by: bluescreen
Priority: normal Milestone:
Component: imcc Version: master
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description (last modified by bluescreen) (diff)

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:

==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)
}}}}

Change History

Changed 4 years ago by bluescreen

  • status changed from new to assigned
  • description modified (diff)

Changed 4 years ago by bluescreen

  • description modified (diff)

Changed 4 years ago by bluescreen

  • description modified (diff)

Changed 4 years ago by bluescreen

  • status changed from assigned to closed
  • resolution set to fixed

Changed 4 years ago by bluescreen

commit b479f4fc24be7cb54da4 fixes the issue

Note: See TracTickets for help on using tickets.