https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91439
Bug ID: 91439 Summary: Wrong debug information with -fsanitize=address Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: aclopte at gmail dot com CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- Similarly to an issue with Clang https://bugs.llvm.org/show_bug.cgi?id=26673, gcc with Address Sanitizer on Arch Linux produces wrong debug information in certain cases. It seems to happen when a function takes as parameter the address of a local variable. Then the debug information describing the location of that variable in the caller is off. gcc version 10.0.0 20190812 (experimental) (GCC) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274308 The same issue occurs with gcc 9.1.0. Linux 5.2.2 gdb 8.3 glibc 2.29 binutils 2.32 # I built with default options: mkdir build && cd build && ../configure && make # This is a minimal test case: cat > x.c <<EOF void f(int *arg) { } int main(int argc, char **argv) { f(&argc); } EOF # compiling and running the program as below with no arguments makes argc=1 # however, printing argc in gdb after entering main shows 2, # which does not change when changing the number of arguments # (with gcc 9.1.0 it is 0 instead of 2) gcc x.c -g -fsanitize=address && gdb -batch ./a.out -ex 'b main' -ex 'run' Breakpoint 1 at 0x4011bd: file x.c, line 3. [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". Breakpoint 1, main (argc=2, argv=0x7fffffffdee8) at x.c:3 3 int main(int argc, char **argv) {