FS#40223 - [gcc] [gdb] Compiling with AddressSanitizer with 4.9 breaks printng some variables in gdb

Attached to Project: Arch Linux
Opened by Krzysztof Kundzicz (Athantor) - Monday, 05 May 2014, 11:16 GMT
Last edited by Allan McRae (Allan) - Saturday, 20 February 2016, 02:21 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Allan McRae (Allan)
Anatol Pomozov (anatolik)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
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 only when debugging 32bit binary; 64bit works OK. It doesn't matter if I'm cross compiling it 64b→32b nor if I compile it natively on i386 version of Arch.
It was working OK with gcc <4.9.

Additional info:
gcc-multilib 4.9.0-1 / gcc 4.9.0-1
gdb 7.7-1
glibc 2.19-4
binutils 2.24-3
Linux kk 3.14.2-1-ARCH #1 SMP PREEMPT Sun Apr 27 11:28:44 CEST 2014 x86_64 GNU/Linux

Steps to reproduce:
Compile attached source file with
gcc -m32 -Wall -Wextra -Wno-unused-variable -fsanitize=address -ggdb3 -O0 -o test test.c
and gdb it with:
gdb --ex 'b main' --ex 'r' --ex 'p d' --ex 'q' ./test

If you'll compile with ASAN, gdb will show that variable 'd' is optimized out despite '-O0' in gcc switches:
Breakpoint 1, main () at test.c:10
10 int d = 4;
$1 = <optimized out>


remove '-fsanitize=address' from switches and gdb works as it should (ignore uninitialized value):
Breakpoint 1, main () at test.c:10
10 int d = 4;
$1 = 134513883


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.

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>

   test.c (0.2 KiB)
This task depends upon

Closed by  Allan McRae (Allan)
Saturday, 20 February 2016, 02:21 GMT
Reason for closing:  Upstream
Comment by Anatol Pomozov (anatolik) - Monday, 05 May 2014, 15:40 GMT
It sounds like a bug in GCC+ASAN integration.

Could you please send this message to ASAN maillist https://groups.google.com/forum/#!forum/address-sanitizer
And/or to GCC community as well?
Comment by Krzysztof Kundzicz (Athantor) - Tuesday, 06 May 2014, 05:33 GMT Comment by Krzysztof Kundzicz (Athantor) - Friday, 22 May 2015, 05:46 GMT
After a year time for new people to join the party :-)

https://code.google.com/p/address-sanitizer/issues/detail?id=390
Comment by Allan McRae (Allan) - Saturday, 20 February 2016, 02:21 GMT
This is an upstream gcc bug, and has a workaround (see link above). Nothing that can be done here - pester upstream for the fix.

Loading...