Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 390 by [email protected]: Compiling with AddressSanitizer using gcc ≥4.9 breaks printng some variables in gdb on Linux
https://code.google.com/p/address-sanitizer/issues/detail?id=390

With certain configurations of variables on function's stack, when debugging 32bit binary compiled with '-fsanitize=address', some variables in gdb are printed out as '<optimized out>' despite passing '-O0 -ggdb3' in compilation
switches.

Problem occurres (for me) only when debugging 32bit binary; same code in 64bit works OK. It doesn't matter if I'm cross compiling it 64b→32b nor if I compile it natively on i386. It was working OK with gcc <4.9. I've checked it on different computers with different distros, and the result is the same since gcc 4.9.


What steps will reproduce the problem?
1. Compile attached source file with:
gcc -m32 -Wall -Wextra -Wno-unused-variable -fsanitize=address -ggdb3 -O0 -o test test.c

2. gdb it with:
gdb --ex 'b 11' --ex 'r' --ex 'p d' --ex 'q' ./test


What is the expected output? What do you see instead?
If you'll compile it with ASAN, gdb will show that variable 'd' is optimized out despite '-O0' in gcc switches:
Breakpoint 1, main () at test.c:11
11              char t[37] = "";
$1 = <optimized out>


remove '-fsanitize=address' from switches and gdb works as it should:
Breakpoint 1, main () at test.c:11
11              char t[37] = "";
$1 = 4


What's funny, if I'll remove zeroing of the 't' array or decrease its size to 36B, then gdb starts to print 'd' OK.
Using clang for compilation also produces debugable binary.

In both cases debug info about the 'd' variable seems to be present in the binary:
<2><be>: Abbrev Number: 8 (DW_TAG_variable)
<bf> DW_AT_name : d
<c1> DW_AT_decl_file : 1
<c2> DW_AT_decl_line : 11
<c3> DW_AT_type : <0x53>


What version of the product are you using? On what operating system?
Arch Linux.
Linux kk 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST 2015 x86_64 GNU/Linux
gcc version 5.1.0 (GCC)
GNU gdb (GDB) 7.9.1
GNU C Library (GNU libc) stable release version 2.21
GNU ld (GNU Binutils 2.25.0)

Please provide any additional information below.
Downstream bug reports:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61071
https://bugs.archlinux.org/task/40223

Attachments:
        test.c  176 bytes
        test.s  87.6 KB

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to