Skip to content

Conversation

sorokin
Copy link
Contributor

@sorokin sorokin commented Feb 26, 2023

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

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x7f17d8a60867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5613fd57401c in nasm_malloc nasmlib/alloc.c:55
    #2 0x5613fd5be840 in dup_text asm/preproc.c:436
    #3 0x5613fd5dc71d in parse_mmacro_spec asm/preproc.c:3325
    #4 0x5613fd5e5f7a in do_directive asm/preproc.c:4615
    #5 0x5613fd5f5e19 in pp_tokline asm/preproc.c:7766
    #6 0x5613fd5f5e19 in pp_getline asm/preproc.c:7830
    #7 0x5613fd56e678 in assemble_file asm/nasm.c:1722
    #8 0x5613fd568801 in main asm/nasm.c:719
    #9 0x7f17d8178d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #10 0x7f17d8178e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #11 0x5613fd56acd4 in _start (/home/ivan/d/nasm/nasm+0x2e5cd4)

SUMMARY: AddressSanitizer: 6 byte(s) leaked in 1 allocation(s).

This error was reproducible on align13s.asm test.

The problem was caused by the fact that do_directive didn't cleaup properly the macro name returned from parse_mmacro_spec.

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

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x7f17d8a60867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    netwide-assembler#1 0x5613fd57401c in nasm_malloc nasmlib/alloc.c:55
    netwide-assembler#2 0x5613fd5be840 in dup_text asm/preproc.c:436
    netwide-assembler#3 0x5613fd5dc71d in parse_mmacro_spec asm/preproc.c:3325
    netwide-assembler#4 0x5613fd5e5f7a in do_directive asm/preproc.c:4615
    netwide-assembler#5 0x5613fd5f5e19 in pp_tokline asm/preproc.c:7766
    netwide-assembler#6 0x5613fd5f5e19 in pp_getline asm/preproc.c:7830
    netwide-assembler#7 0x5613fd56e678 in assemble_file asm/nasm.c:1722
    netwide-assembler#8 0x5613fd568801 in main asm/nasm.c:719
    netwide-assembler#9 0x7f17d8178d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    netwide-assembler#10 0x7f17d8178e3f in __libc_start_main_impl ../csu/libc-start.c:392
    netwide-assembler#11 0x5613fd56acd4 in _start (/home/ivan/d/nasm/nasm+0x2e5cd4)

SUMMARY: AddressSanitizer: 6 byte(s) leaked in 1 allocation(s).

This error was reproducible on align13s.asm test.

The problem was caused by the fact that do_directive didn't
cleaup properly the macro name returned from parse_mmacro_spec.

Signed-off-by: Ivan Sorokin <[email protected]>
@sorokin sorokin force-pushed the fix-memory-leak-of-mmacro-name-in-undef branch from 49030a2 to ad74ce7 Compare March 5, 2023 20:11
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