==638106==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_thread.cpp:369 "((bottom)) != (0)" (0x0, 0x0) #0 0x7f00888e08b8 (/lib/x86_64-linux-gnu/libasan.so.6+0xb98b8) #1 0x7f00889007ce (/lib/x86_64-linux-gnu/libasan.so.6+0xd97ce) #2 0x7f00888e64f0 (/lib/x86_64-linux-gnu/libasan.so.6+0xbf4f0) #3 0x7f00888dd68b (/lib/x86_64-linux-gnu/libasan.so.6+0xb668b) #4 0x7f00888e0269 in __sanitizer_ptr_sub (/lib/x86_64-linux-gnu/libasan.so.6+0xb9269) #5 0x55e8cd6641f2 in pointer_diff(int const*, int const*) /home/chfast/Projects/compiler_bugs/sanitizers/pointer_subtract_crash/pointer_subtract_crash.cpp:2 #6 0x55e8cd664248 in main /home/chfast/Projects/compiler_bugs/sanitizers/pointer_subtract_crash/pointer_subtract_crash.cpp:10 #7 0x7f008865c0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) #8 0x55e8cd66410d in _start (/home/chfast/Projects/compiler_bugs/sanitizers/pointer_subtract_crash/a.out+0x110d) When running the program [[gnu::noinline]] auto pointer_diff(const int *begin, const int *end) { return end - begin; } int main() { constexpr auto size = (2048 / sizeof(int)) + 1; auto buf = new int[size]; auto end = buf + size; pointer_diff(end, buf); delete[] buf; return 0; } compiled with gcc -fsanitize=address,pointer-subtract -g pointer_subtract_crash.cpp To reproduce the crash, both runtime options must be enabled: ASAN_OPTIONS=detect_stack_use_after_return=1:detect_invalid_pointer_pairs=1 This bug was previously reported in LLVM's AddressSanitizer project https://bugs.llvm.org/show_bug.cgi?id=47626, but pointer-subtract is not supported there.
Confirmed, I'll take a look at it. Thank you for the bug report.
*** Bug 97416 has been marked as a duplicate of this bug. ***
I've just an upstream fix: https://reviews.llvm.org/D89552
Waiting for upstream to apply the fix.
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:6c5b08a2ca935c5db68e79d33e5c5b752252115c commit r11-4177-g6c5b08a2ca935c5db68e79d33e5c5b752252115c Author: Martin Liska <mliska@suse.cz> Date: Wed Oct 21 09:28:56 2020 +0200 libsanitizer: add test-case gcc/testsuite/ChangeLog: PR sanitizer/97414 * g++.dg/asan/pr97414.C: New test.
Fixed on master so far.
The releases/gcc-10 branch has been updated by Martin Liska <marxin@gcc.gnu.org>: https://gcc.gnu.org/g:98cd020ebc50a197de17aecd15afdff718cb06d3 commit r10-8932-g98cd020ebc50a197de17aecd15afdff718cb06d3 Author: Martin Liska <mliska@suse.cz> Date: Wed Oct 21 09:28:56 2020 +0200 libsanitizer: add test-case gcc/testsuite/ChangeLog: PR sanitizer/97414 * g++.dg/asan/pr97414.C: New test. (cherry picked from commit 6c5b08a2ca935c5db68e79d33e5c5b752252115c)
Fixed on all active branches.