Memory Leak in mb_exec_compile #12

Closed
opened 2023-07-03 22:20:51 +02:00 by MarieEckert · 1 comment
MarieEckert commented 2023-07-03 22:20:51 +02:00 (Migrated from github.com)

A memory leak is caused by mb_exec_compile on line 164 in mb_execute.c

Valgrind Log:

==14573== Memcheck, a memory error detector
==14573== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==14573== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==14573== Command: ./mb -m release
==14573==
>> Executing script prepare...
==14573== Invalid read of size 8
==14573==    at 0x10BFA4: mb_exec_compile (mb_execute.c:164)
==14573==    by 0x10C318: mb_exec_build (mb_execute.c:232)
==14573==    by 0x10C798: main (mb.c:135)
==14573==  Address 0x4a70f98 is 152 bytes inside a block of size 192 free'd
==14573==    at 0x4846BE0: realloc (vg_replace_malloc.c:1649)
==14573==    by 0x10A09B: register_field (mb_parse.c:143)
==14573==    by 0x10BF1F: mb_exec_compile (mb_execute.c:154)
==14573==    by 0x10C318: mb_exec_build (mb_execute.c:232)
==14573==    by 0x10C798: main (mb.c:135)
==14573==  Block was alloc'd at
==14573==    at 0x4846BE0: realloc (vg_replace_malloc.c:1649)
==14573==    by 0x10A09B: register_field (mb_parse.c:143)
==14573==    by 0x10BB40: mb_exec_prepare_mode (mb_execute.c:91)
==14573==    by 0x10C2EA: mb_exec_build (mb_execute.c:227)
==14573==    by 0x10C798: main (mb.c:135)
==14573==
>> gcc -O3 -Wall -Iinclude/ -c -o out/mb_utils.c.o src/mb_utils.c
>> gcc -O3 -Wall -Iinclude/ -c -o out/mb_parse.c.o src/mb_parse.c
>> gcc -O3 -Wall -Iinclude/ -c -o out/mb_script.c.o src/mb_script.c
>> gcc -O3 -Wall -Iinclude/ -c -o out/mb_execute.c.o src/mb_execute.c
>> gcc -O3 -Wall -Iinclude/ -c -o out/mb.c.o src/mb.c
>> gcc -O3 -o mb out/mb_utils.c.o out/mb_parse.c.o out/mb_script.c.o out/mb_execute.c.o out/mb.c.o
>> Build succeeded!
==14573==
==14573== HEAP SUMMARY:
==14573==     in use at exit: 16 bytes in 1 blocks
==14573==   total heap usage: 872 allocs, 871 frees, 21,071 bytes allocated
==14573==
==14573== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1
==14573==    at 0x4841848: malloc (vg_replace_malloc.c:431)
==14573==    by 0x10BBEB: mb_exec_prepare_mode (mb_execute.c:106)
==14573==    by 0x10C2EA: mb_exec_build (mb_execute.c:227)
==14573==    by 0x10C798: main (mb.c:135)
==14573==
==14573== LEAK SUMMARY:
==14573==    definitely lost: 16 bytes in 1 blocks
==14573==    indirectly lost: 0 bytes in 0 blocks
==14573==      possibly lost: 0 bytes in 0 blocks
==14573==    still reachable: 0 bytes in 0 blocks
==14573==         suppressed: 0 bytes in 0 blocks
==14573==
==14573== For lists of detected and suppressed errors, rerun with: -s
==14573== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0)
A memory leak is caused by mb_exec_compile on line 164 in mb_execute.c Valgrind Log: ``` ==14573== Memcheck, a memory error detector ==14573== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==14573== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info ==14573== Command: ./mb -m release ==14573== >> Executing script prepare... ==14573== Invalid read of size 8 ==14573== at 0x10BFA4: mb_exec_compile (mb_execute.c:164) ==14573== by 0x10C318: mb_exec_build (mb_execute.c:232) ==14573== by 0x10C798: main (mb.c:135) ==14573== Address 0x4a70f98 is 152 bytes inside a block of size 192 free'd ==14573== at 0x4846BE0: realloc (vg_replace_malloc.c:1649) ==14573== by 0x10A09B: register_field (mb_parse.c:143) ==14573== by 0x10BF1F: mb_exec_compile (mb_execute.c:154) ==14573== by 0x10C318: mb_exec_build (mb_execute.c:232) ==14573== by 0x10C798: main (mb.c:135) ==14573== Block was alloc'd at ==14573== at 0x4846BE0: realloc (vg_replace_malloc.c:1649) ==14573== by 0x10A09B: register_field (mb_parse.c:143) ==14573== by 0x10BB40: mb_exec_prepare_mode (mb_execute.c:91) ==14573== by 0x10C2EA: mb_exec_build (mb_execute.c:227) ==14573== by 0x10C798: main (mb.c:135) ==14573== >> gcc -O3 -Wall -Iinclude/ -c -o out/mb_utils.c.o src/mb_utils.c >> gcc -O3 -Wall -Iinclude/ -c -o out/mb_parse.c.o src/mb_parse.c >> gcc -O3 -Wall -Iinclude/ -c -o out/mb_script.c.o src/mb_script.c >> gcc -O3 -Wall -Iinclude/ -c -o out/mb_execute.c.o src/mb_execute.c >> gcc -O3 -Wall -Iinclude/ -c -o out/mb.c.o src/mb.c >> gcc -O3 -o mb out/mb_utils.c.o out/mb_parse.c.o out/mb_script.c.o out/mb_execute.c.o out/mb.c.o >> Build succeeded! ==14573== ==14573== HEAP SUMMARY: ==14573== in use at exit: 16 bytes in 1 blocks ==14573== total heap usage: 872 allocs, 871 frees, 21,071 bytes allocated ==14573== ==14573== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==14573== at 0x4841848: malloc (vg_replace_malloc.c:431) ==14573== by 0x10BBEB: mb_exec_prepare_mode (mb_execute.c:106) ==14573== by 0x10C2EA: mb_exec_build (mb_execute.c:227) ==14573== by 0x10C798: main (mb.c:135) ==14573== ==14573== LEAK SUMMARY: ==14573== definitely lost: 16 bytes in 1 blocks ==14573== indirectly lost: 0 bytes in 0 blocks ==14573== possibly lost: 0 bytes in 0 blocks ==14573== still reachable: 0 bytes in 0 blocks ==14573== suppressed: 0 bytes in 0 blocks ==14573== ==14573== For lists of detected and suppressed errors, rerun with: -s ==14573== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0) ```
MarieEckert commented 2023-07-09 21:41:55 +02:00 (Migrated from github.com)

fixed with commit 95da7c0

fixed with commit [95da7c0](https://github.com/FelixEcker/mariebuild/commit/95da7c016aa6b1311b39b0f02a7719da4640a5ef)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marie/mariebuild#12
No description provided.