Trying to run gdb with AddressSanitizer leads to an abort with an alloc/dealloc mismatch reported. This is reproducible both in rawhide (gdb-8.0.1-30.fc28.x86_64) and in Fedora 26 (gdb-8.0.1-26.fc26.x86_64). Steps: a) install libasan b) in terminal: $ export ASAN_OPTIONS=alloc_dealloc_mismatch=1 $ LD_PRELOAD=/usr/lib64/libasan.so.4 gdb Result: ================================================================= ==15496==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x613000000040 #0 0x7f2a0f2bffd0 in operator delete(void*) (/usr/lib64/libasan.so.4+0xe0fd0) #1 0x56437b484f52 (/usr/libexec/gdb+0x1c0f52) #2 0x56437b71d87e (/usr/libexec/gdb+0x45987e) #3 0x56437b6f00d4 (/usr/libexec/gdb+0x42c0d4) #4 0x56437b66634f (/usr/libexec/gdb+0x3a234f) #5 0x56437b3d0bca (/usr/libexec/gdb+0x10cbca) #6 0x7f2a0bcf0106 in __libc_start_main (/lib64/libc.so.6+0x21106) #7 0x56437b3d2cf9 (/usr/libexec/gdb+0x10ecf9) 0x613000000040 is located 0 bytes inside of 334-byte region [0x613000000040,0x61300000018e) allocated by thread T0 here: #0 0x7f2a0f2bd850 in malloc (/usr/lib64/libasan.so.4+0xde850) #1 0x56437b675840 in operator new(unsigned long) (/usr/libexec/gdb+0x3b1840) SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/usr/lib64/libasan.so.4+0xe0fd0) in operator delete(void*) ==15496==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0 ==15496==ABORTING
GDB just isn't ASAN compatible, there are many bugs regarding that. I was posting some ASAN-compatibility patches in the past upstream (but they did not get accepted).
Okay, it's just a pain if I want to run my application under ASAN and I want to run it under gdb at the same time, which is not possible without turning off one feature of ASAN. My usual ASAN options are rich: ASAN_OPTIONS=abort_on_error=1:detect_stack_use_after_return=0:detect_leaks=0: handle_segv=0:check_printf=0:detect_deadlocks=1:replace_str=1: replace_intrin=1:alloc_dealloc_mismatch=1:new_delete_type_mismatch=1: detect_container_overflow=1:symbolize=1
I forgot to add: feel free to close this, especially if upstream doesn't care.
(In reply to Milan Crha from comment #2) > Okay, it's just a pain if I want to run my application under ASAN and I want > to run it under gdb at the same time, which is not possible without turning > off one feature of ASAN. I do not understand this. Are you aware you can use: (gdb) set env LD_PRELOAD=... (gdb) set env ASAN_OPTIONS=... which do apply to the debuggee but not to GDB?
(In reply to Jan Kratochvil from comment #4) > Are you aware you can use: ... Nope, I'm not. Imagine my workflow, please: a) I have a script which sets environment variables as needed, including ASAN things b) I run the script when I open a terminal c) I do changes in my code and run the updated executable d) when it crashes, I want to debug in gdb, sometimes, but I cannot do it in the same terminal. It makes it inconvenient. Your suggested gdb commands can workaround the issue with not being able to run gdb under ASAN. Thanks.
This message is a reminder that Fedora 26 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '26'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 26 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
gdb-8.1-14.fc29.x86_64 libasan-8.0.1-0.23.fc29.x86_64 ASAN_OPTIONS=alloc_dealloc_mismatch=1 LD_PRELOAD=/usr/lib64/libasan.so.5 gdb ================================================================= ==3458440==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6020000000d0 #0 0x7f8420830788 in operator delete(void*) (/usr/lib64/libasan.so.5+0xf1788) #1 0x5573f943d6e7 (/usr/libexec/gdb+0x2896e7) #2 0x5573f943d5c8 (/usr/libexec/gdb+0x2895c8) #3 0x5573f943cf68 (/usr/libexec/gdb+0x288f68) #4 0x5573f956e770 (/usr/libexec/gdb+0x3ba770) #5 0x5573f92e81de (/usr/libexec/gdb+0x1341de) #6 0x7f841d5921ea in __libc_start_main (/lib64/libc.so.6+0x231ea) #7 0x5573f92eada9 (/usr/libexec/gdb+0x136da9) 0x6020000000d0 is located 0 bytes inside of 4-byte region [0x6020000000d0,0x6020000000d4) allocated by thread T0 here: #0 0x7f842082dc88 in malloc (/usr/lib64/libasan.so.5+0xeec88) #1 0x5573f943e614 in operator new(unsigned long) (/usr/libexec/gdb+0x28a614) SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/usr/lib64/libasan.so.5+0xf1788) in operator delete(void*) ==3458440==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0 ==3458440==ABORTING
This bug appears to have been reported against 'rawhide' during the Fedora 29 development cycle. Changing version to '29'.
This message is a reminder that Fedora 29 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '29'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 29 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
gdb-9.0.50.20191018-1.fc32.x86_64 ASAN_OPTIONS=alloc_dealloc_mismatch=1 LD_PRELOAD=/usr/lib64/libasan.so.5 gdb ================================================================= ==13069==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete []) on 0x602000000050 #0 0x7fb6680beb3f in operator delete[](void*) (/usr/lib64/libasan.so.5+0x110b3f) #1 0x7fb667674577 in std::__cxx11::collate<char>::do_transform(char const*, char const*) const (/lib64/libstdc++.so.6+0xf5577) #2 0x7fb66703285c in boost::re_detail_106900::cpp_regex_traits_implementation<char>::transform[abi:cxx11](char const*, char const*) const (/lib64/libboost_regex.so.1.69.0+0x6985c) #3 0x7fb667033318 (/lib64/libboost_regex.so.1.69.0+0x6a318) #4 0x7fb66703775e in boost::re_detail_106900::cpp_regex_traits_implementation<char>::init() (/lib64/libboost_regex.so.1.69.0+0x6e75e) #5 0x7fb667037fe1 (/lib64/libboost_regex.so.1.69.0+0x6efe1) #6 0x7fb66704215b in boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int) (/lib64/libboost_regex.so.1.69.0+0x7915b) #7 0x7fb6677b6e53 (/lib64/libsource-highlight.so.4+0x3de53) #8 0x7fb6689f2dc9 in call_init.part.0 (/lib64/ld-linux-x86-64.so.2+0x10dc9) #9 0x7fb6689f2ed0 in _dl_init (/lib64/ld-linux-x86-64.so.2+0x10ed0) #10 0x7fb6689e4149 (/lib64/ld-linux-x86-64.so.2+0x2149) 0x602000000050 is located 0 bytes inside of 2-byte region [0x602000000050,0x602000000052) allocated by thread T0 here: #0 0x7fb6680bbc58 in __interceptor_malloc (/usr/lib64/libasan.so.5+0x10dc58) #1 0x561d7e59258e in operator new(unsigned long) (/usr/libexec/gdb+0x2fd58e) SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/usr/lib64/libasan.so.5+0x110b3f) in operator delete[](void*) ==13069==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0 ==13069==ABORTING
This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle. Changing version to 32.
This message is a reminder that Fedora 32 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '32'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 32 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
[patch] Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb https://sourceware.org/pipermail/gdb-patches/2021-May/178413.html