Describe the bug
When running tests (and other options) see ASAN reporting memory leaks when shutting down
To Reproduce
Steps to reproduce the behavior:
./configure --enabla-asan
make
sudo make test
Expected behavior
No errors
Screenshots
Get many failures which when investigated review memory leaks, e.g.
sudo ../src/tcprewrite -d1 -i test.pcap -o test.rewrite_range_portmap1 -r 1-2:49148
DEBUG1 in tcpedit.c:tcpedit_init() line 408: Input file (1) datalink type is EN10MB
DEBUG1 in tcprewrite.c:main() line 105: Rewriting DLT to EN10MB
DEBUG1 in tcprewrite.c:main() line 110: DLT of dlt_pcap is EN10MB
DEBUG1 in utils.c:_our_safe_pcap_next() line 151: No data found in packet
=================================================================
==99969==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fb620b34330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x5633517abcbb in _our_safe_malloc /home/fklassen/git/tcpreplay/src/common/utils.c:50
#2 0x56335178a7e3 in new_portmap /home/fklassen/git/tcpreplay/src/tcpedit/portmap.c:46
#3 0x56335178ad1c in ports2PORT /home/fklassen/git/tcpreplay/src/tcpedit/portmap.c:127
#4 0x56335178b481 in parse_portmap /home/fklassen/git/tcpreplay/src/tcpedit/portmap.c:197
#5 0x56335178201b in tcpedit_post_args /home/fklassen/git/tcpreplay/src/tcpedit/parse_args.c:191
#6 0x56335177b2d5 in main /home/fklassen/git/tcpreplay/src/tcprewrite.c:87
#7 0x7fb62022009a in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).
sudo ../src/tcpprep -i test.pcap -o test.exclude_packets1 -c '96.17.211.0/24' --exclude 'P:61-65,88-91'
=================================================================
==100169==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 256 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a850319 in __GI___regcomp /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:478
Direct leak of 224 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa720 in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
#1 0x7f8f3a84f97c in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:763
Indirect leak of 8192 byte(s) in 4 object(s) allocated from:
#0 0x7f8f3b0aa518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f8f3a8452ea in build_trtable /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:3424
#2 0x7f8f3a84b0af in transit_state /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:2271
#3 0x7f8f3a84b0af in check_matching /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:1133
#4 0x7f8f3a84b0af in re_search_internal /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:802
Indirect leak of 616 byte(s) in 7 object(s) allocated from:
#0 0x7f8f3b0aa518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f8f3a843fae in create_cd_newstate /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1678
#2 0x7f8f3a843fae in re_acquire_state_context /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1553
Indirect leak of 512 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f8f3a84ee43 in init_dfa /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:878
#2 0x7f8f3a84ee43 in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:771
Indirect leak of 352 byte(s) in 4 object(s) allocated from:
#0 0x7f8f3b0aa518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f8f3a843fae in create_cd_newstate /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1678
#2 0x7f8f3a843fae in re_acquire_state_context /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1553
#3 0x7f8f3a84b0af in transit_state /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:2271
#4 0x7f8f3a84b0af in check_matching /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:1133
#5 0x7f8f3a84b0af in re_search_internal /build/glibc-vjB4T1/glibc-2.28/posix/regexec.c:802
Indirect leak of 308 byte(s) in 21 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a843ce6 in re_node_set_init_copy /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1033
Indirect leak of 304 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a84f208 in analyze /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1183
#2 0x7f8f3a84f208 in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:808
Indirect leak of 304 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a84f1f7 in analyze /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1182
#2 0x7f8f3a84f1f7 in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:808
Indirect leak of 304 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a84ee0e in init_dfa /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:871
#2 0x7f8f3a84ee0e in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:771
Indirect leak of 160 byte(s) in 10 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a84417d in create_cd_newstate /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1713
#2 0x7f8f3a84417d in re_acquire_state_context /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1553
Indirect leak of 142 byte(s) in 11 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a841775 in re_node_set_alloc /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:973
#2 0x7f8f3a841775 in register_state /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1574
Indirect leak of 128 byte(s) in 8 object(s) allocated from:
#0 0x7f8f3b0aa720 in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
#1 0x7f8f3a841821 in register_state /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1589
Indirect leak of 76 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a84f1d9 in analyze /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1180
#2 0x7f8f3a84f1d9 in re_compile_internal /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:808
Indirect leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x7f8f3b0aa518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f8f3a84d51d in parse_bracket_exp /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:3130
#2 0x7f8f3a84d51d in parse_expression /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:2302
Indirect leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa720 in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
#1 0x7f8f3a8438c4 in re_node_set_merge /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1204
#2 0x60200000018f (<unknown module>)
Indirect leak of 48 byte(s) in 10 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a843969 in re_node_set_alloc /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:973
#2 0x7f8f3a843969 in calc_eclosure_iter /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1714
Indirect leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa720 in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
#1 0x7f8f3a8438c4 in re_node_set_merge /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1204
#2 0x60200000026f (<unknown module>)
Indirect leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7f8f3b0aa720 in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
#1 0x7f8f3a8438c4 in re_node_set_merge /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1204
#2 0x6020000001af (<unknown module>)
Indirect leak of 24 byte(s) in 3 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a8418eb in re_node_set_init_2 /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:1000
#2 0x7f8f3a8418eb in link_nfa_nodes /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1467
Indirect leak of 8 byte(s) in 2 object(s) allocated from:
#0 0x7f8f3b0aa330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f8f3a841998 in re_node_set_init_1 /build/glibc-vjB4T1/glibc-2.28/posix/regex_internal.c:985
#2 0x7f8f3a841998 in link_nfa_nodes /build/glibc-vjB4T1/glibc-2.28/posix/regcomp.c:1480
SUMMARY: AddressSanitizer: 12158 byte(s) leaked in 92 allocation(s).
System (please complete the following information):
OS: Debian (Linux)
Buster
Tcpreplay Version 4.3.4 Beta1
Additional context
Also found in Bug #582 when converting from RAW to EN10MB
src/tcprewrite --infile=10packets.pcap --outfile=10packets_trunc2.pcap --dlt=enet --enet-dmac=11:22:33:44:55:66 --enet-smac=00:11:22:33:44:55 --fixlen=trunc
=================================================================
==100475==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 262166 byte(s) in 1 object(s) allocated from:
#0 0x7f510d358330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x5558409cdcbb in _our_safe_malloc /home/fklassen/git/tcpreplay/src/common/utils.c:50
#2 0x5558409bbce9 in dlt_raw_init plugins/dlt_raw/raw.c:108
#3 0x5558409b12cd in tcpedit_dlt_init plugins/dlt_plugins.c:160
#4 0x5558409a19bb in tcpedit_init /home/fklassen/git/tcpreplay/src/tcpedit/tcpedit.c:390
#5 0x55584099d23d in main /home/fklassen/git/tcpreplay/src/tcprewrite.c:82
#6 0x7f510ca4409a in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: 262166 byte(s) leaked in 1 allocation(s).
Describe the bug When running tests (and other options) see ASAN reporting memory leaks when shutting down
To Reproduce Steps to reproduce the behavior:
Expected behavior No errors
Screenshots Get many failures which when investigated review memory leaks, e.g.
System (please complete the following information):
Additional context Also found in Bug #582 when converting from RAW to EN10MB