Hi,

I posted this on cfe-dev before, but perhaps this is more appropriate.

I noticed that debugging of AddressSanitizer-instrumented clang debug binaries
is basically impossible since all the symbols are optimized out. It looks like
there is something wrong with debug info. I'm getting the same behavior
on 3.4 and trunk. Interestingly it works for -fsanitize=undefined. Is this a 
known
issue? There are several related bugs but they are fixed already, e.g.
http://llvm.org/bugs/show_bug.cgi?id=11818
 
# cat UnitAsanStackOOB.cpp
int main()
{
    const int len = 10;
    char buffer[len];
    char *p = &buffer[0];
    p[len] = 1;
    return 0;
}

# clang++ -g -o oob_trunk_add -fsanitize=address UnitAsanStackOOB.cpp
# gdb oob_trunk_add
GNU gdb (GDB) 7.5.1
Reading symbols from 
/local/build/git5/sys/src/clang/AddressSanitizer/test/oob_trunk_add...done.
(gdb) b main
Breakpoint 1 at 0x495a4a: file UnitAsanStackOOB.cpp, line 3.
(gdb) run
Starting program: 
/local/build/git5/sys/src/clang/AddressSanitizer/test/oob_trunk_add
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 1, main () at UnitAsanStackOOB.cpp:3
3           const int len = 10;
(gdb) n
5           char *p = &buffer[0];
(gdb) n
6           p[len] = 1;
(gdb) p p
$1 = <optimized out>
(gdb) p len
$2 = <optimized out>

# clang++ -g -o oob_trunk_und -fsanitize=undefined UnitAsanStackOOB.cpp
# gdb oob_trunk_und
GNU gdb (GDB) 7.5.1
 (gdb) b main
Breakpoint 1 at 0x426280: file UnitAsanStackOOB.cpp, line 2.
(gdb) run
Starting program: 
/local/build/git5/sys/src/clang/AddressSanitizer/test/oob_trunk_und
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 1, main () at UnitAsanStackOOB.cpp:2
2       {
(gdb) n
3           const int len = 10;
(gdb) n
5           char *p = &buffer[0];
(gdb) n
6           p[len] = 1;
(gdb) p p
$1 = 0x7fffffff975e ""
(gdb) p len
$2 = 10

# clang++ -v
clang version 3.5.0 (trunk 204863)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.3
Selected GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.3
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

Best regards,
Martin

-- 
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