Bug 1250844

Summary: GCC and libasan missing asan_symbolize
Product: [Fedora] Fedora Reporter: Jeffrey Walton <noloader>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: davejohansen, jakub, jwakely, law, mpolacek, noloader
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-01 21:51:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
asan_symbolize for GCC 4.8 none

Description Jeffrey Walton 2015-08-06 06:56:25 UTC
I installed GCC. I then installed libasan-5.1.1-4.fc22. Next, I tried to run the following command:

    export CXXFLAGS="-fsanitize=address"
    make
    <copy to working directory>
    ./my_test.exe 2>&1 | sed "s|<old path>|<new path>|g" | asan_symbolize

The command resulted in:

    bash: asan_symbolize: command not found...

Searching for the following resulted in 0 hits:

    $ find /usr -name asan_symbolize
    /usr/local/bin/asan_symbolize
    $ find /usr -name asan_symbolize.py
    /usr/local/bin/asan_symbolize.py
    $

According to the Asan folks, pipe'ing to asan_symbolize is the way to handle a quick and dirty relocation of the program (https://groups.google.com/d/msg/address-sanitizer/OTzWjoZIfhY/NwdF3FKL5JAJ).

Asan symbolize is available at https://code.google.com/p/address-sanitizer/.

**********

$ lsb_release
LSB Version:	:core-4.1-amd64:core-4.1-noarch

$ uname -a
Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22 UTC

$ yum list installed | grep gcc
Yum command has been deprecated, redirecting to '/usr/bin/dnf list installed'.
See 'man dnf' and 'man yum2dnf' for more information.

gcc.x86_64                              5.1.1-4.fc22                     @System
gcc-c++.x86_64                          5.1.1-4.fc22                     @System
libgcc.x86_64                           5.1.1-1.fc22                     @System
libgcc.x86_64                           5.1.1-4.fc22                     @System

**********

Related, I seem to recall I had to install libubsan and libasan separately after installing GCC. If this is the case, then perhaps libubsan and libasan should be installed with GCC.

Comment 1 Jeffrey Walton 2015-08-06 06:57:57 UTC
> 
> Searching for the following resulted in 0 hits:
> 
>     $ find /usr -name asan_symbolize
>     /usr/local/bin/asan_symbolize
>     $ find /usr -name asan_symbolize.py
>     /usr/local/bin/asan_symbolize.py
>     $

My pad, these should have been empty. The files are present above because I copied them from another machine.

Comment 2 Jakub Jelinek 2016-02-01 21:51:04 UTC
You don't need to do that with gcc, libsanitizer in gcc uses libbacktrace to symbolize the output already.

Comment 3 Jeffrey Walton 2016-06-27 02:22:29 UTC
(In reply to Jakub Jelinek from comment #2)
> You don't need to do that with gcc, libsanitizer in gcc uses libbacktrace to
> symbolize the output already.

Thanks Jakub.

I keep hitting problems like below. Are you certain GCC goes not need a symbolizer for Asan?

**********

These are from a log file, so line numbers are added in front of the actual error reported by the tools.

41205:==1317== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbec57b18 at pc 0x38c651 bp 0xbec579e0 sp 0xbec579e4


41499:==1321== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbedbae9c at pc 0x6553f bp 0xbedbae68 sp 0xbedbae6c


41740:==2793== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbea67b18 at pc 0x38cbc5 bp 0xbea679e0 sp 0xbea679e4


42034:==2797== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbef0fe9c at pc 0x66117 bp 0xbef0fe68 sp 0xbef0fe6c

**********

$ uname -a
Linux cubietruck 3.4.39 #35 SMP PREEMPT Tue Sep 15 17:17:33 CST 2015 armv7l armv7l armv7l GNU/Linux

$ g++ --version
g++ (Ubuntu/Linaro 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.

Comment 4 Jeffrey Walton 2016-06-27 03:10:25 UTC
> These are from a log file, so line numbers are added in front of the actual
> error reported by the tools.
> 
> 41205:==1317== ERROR: AddressSanitizer: stack-buffer-overflow on address
> 0xbec57b18 at pc 0x38c651 bp 0xbec579e0 sp 0xbec579e4
> 
> 
> 41499:==1321== ERROR: AddressSanitizer: stack-buffer-overflow on address
> 0xbedbae9c at pc 0x6553f bp 0xbedbae68 sp 0xbedbae6c
> 
> 
> 41740:==2793== ERROR: AddressSanitizer: stack-buffer-overflow on address
> 0xbea67b18 at pc 0x38cbc5 bp 0xbea679e0 sp 0xbea679e4
> 
> 
> 42034:==2797== ERROR: AddressSanitizer: stack-buffer-overflow on address
> 0xbef0fe9c at pc 0x66117 bp 0xbef0fe68 sp 0xbef0fe6c

For completeness, the program being tested always uses -g2 (release build) and -g3 (debug build). -g is never omitted.

Comment 5 Jeffrey Walton 2016-07-02 07:56:27 UTC
(In reply to Jeffrey Walton from comment #3)
> (In reply to Jakub Jelinek from comment #2)
> > You don't need to do that with gcc, libsanitizer in gcc uses libbacktrace to
> > symbolize the output already.
> 
> Thanks Jakub.
> 
> I keep hitting problems like below. Are you certain GCC goes not need a
> symbolizer for Asan?
> 

I don't know what is different about things on my CubieTruck5 (Linaro, GCC 4.8.2), but I had to use asan_symbolize provided by Clang/Asan to get symbols for a GCC/Asan finding.

Also see http://lists.linaro.org/pipermail/linaro-toolchain/2016-June/005786.html (start of thread) and http://lists.linaro.org/pipermail/linaro-toolchain/2016-July/005795.html (end of thread). The 005795 link includes an attachment for asan_symbolize from Clang, which can be used to get symbols from GCC/Asan findings.

Comment 6 Jakub Jelinek 2016-07-02 07:59:10 UTC
(In reply to Jeffrey Walton from comment #5)
> I don't know what is different about things on my CubieTruck5 (Linaro, GCC
> 4.8.2), but I had to use asan_symbolize provided by Clang/Asan to get
> symbols for a GCC/Asan finding.

Everything is different in this regard between 4.8.x and 4.9.x.  Only the latter has libbacktrace symbolization built in, the former doesn't have any symbolization.

Comment 7 Jeffrey Walton 2016-07-02 17:12:52 UTC
Created attachment 1175375 [details]
asan_symbolize for GCC 4.8

Attached is an asan_symbolize which can be used for GCC 4.8.

The shebang is '/usr/bin/env python'. Someone may want to change it to '/usr/bin/env python2'.

Alternately, run '2to3' on it and fix the three issues that surface. Also see http://github.com/google/sanitizers/issues/372.