Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory leak in -E mode #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sorokin
Copy link

@sorokin sorokin commented Feb 26, 2023

When running with -fsanitize=leak enabled nasm prints these errors:

Direct leak of 114 byte(s) in 10 object(s) allocated from:
    #0 0x7f3031ef0867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x564dc07a2f6c in nasm_malloc nasmlib/alloc.c:55
    #2 0x564dc07f606a in detoken asm/preproc.c:2029
    #3 0x564dc0828a62 in pp_getline asm/preproc.c:7835
    #4 0x564dc0797f3e in main asm/nasm.c:654
    #5 0x7f3031608d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #6 0x7f3031608e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #7 0x564dc0799c24 in _start (/home/ivan/d/nasm/nasm+0x2e5c24)

Direct leak of 10 byte(s) in 10 object(s) allocated from:
    #0 0x7f3031ef0867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x564dc07a2f6c in nasm_malloc nasmlib/alloc.c:55
    #2 0x564dc07f64f9 in detoken asm/preproc.c:2029
    #3 0x564dc0828a62 in pp_getline asm/preproc.c:7835
    #4 0x564dc0797f3e in main asm/nasm.c:654
    #5 0x7f3031608d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #6 0x7f3031608e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #7 0x564dc0799c24 in _start (/home/ivan/d/nasm/nasm+0x2e5c24)

This is reproducible on tests that do preprocessing for example weirdpaste test.

The problem is caused by the fact that the line returned by pp_getline isn't freed in main function.

When running with -fsanitize=leak enabled nasm prints this error:

Direct leak of 114 byte(s) in 10 object(s) allocated from:
    #0 0x7f3031ef0867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    netwide-assembler#1 0x564dc07a2f6c in nasm_malloc nasmlib/alloc.c:55
    netwide-assembler#2 0x564dc07f606a in detoken asm/preproc.c:2029
    netwide-assembler#3 0x564dc0828a62 in pp_getline asm/preproc.c:7835
    netwide-assembler#4 0x564dc0797f3e in main asm/nasm.c:654
    netwide-assembler#5 0x7f3031608d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    netwide-assembler#6 0x7f3031608e3f in __libc_start_main_impl ../csu/libc-start.c:392
    netwide-assembler#7 0x564dc0799c24 in _start (/home/ivan/d/nasm/nasm+0x2e5c24)

This is reproducible on tests that do preprocessing for example
weirdpaste.asm test.

The problem is caused by the fact that the line returned by pp_getline
isn't freed in main function.

Signed-off-by: Ivan Sorokin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant