JovianPyx
Posts: 121
Joined: Fri Nov 20, 2015 9:34 pm

Using Sanatize Address

Wed Jan 04, 2017 6:22 pm

I have a need to be able to use address sanitize with GCC. I have more than one Rpi3, two has Arch Linux, the other two have Raspbian. On the Arch system, gcc version is 6.1.1 20160501. On Raspbian, gcc version is 4.9.2. I have installed the clang package on both.

The compile works without errors on the Raspbian system and the program executes correctly giving the hints about where the out of bounds access exists.

However, when I compile the target C program on the Arch system, I see this:

Code: Select all

/usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
/usr/bin/ld: cannot find -lasan
and I don't seem to be able find an 'asan.so' anywhere (which makes sense given the error message).

The compile command I use (on both) is:

Code: Select all

gcc array_out_of_bounds_test.c -std=c99 -Wall -Wextra -O2 -fsanitize=address -o /usr/local/bin/array_out_of_bounds_test
The C program is a simple test program that ought to bark out an error about out of bounds access, but it always returns the gcc/ld error message about asan.

Using google, I've seen more than one reference to the library not being installed, so I've come here to find out what to do. I had started by trying to use mudflap, but apparently that is now gone. I'd prefer to work in Arch, but this has me stymied.

Being able to include address sanitize code would help me immensely, I'm working on a large multi-thread application that is failing in a way that suggests out of bounds array access and runtime error/warnings from asan would probably be very helpful.

- Is this just not part of GCC for Arch Linux on ARM8 (Rpi3)?
- Is there some detail I've missed in how I issue my compile or how to compile under Arch?
- Did I not properly install clang on Arch (or is it broken)?

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Using Sanatize Address

Wed Jan 04, 2017 9:52 pm

Not sure is this helps.

On my machines libasan.so is in /usr/local/lib or /usr/local/lib64, installed with GCC.

I just set LD_LIBRARY_PATH before running the test program.

JovianPyx
Posts: 121
Joined: Fri Nov 20, 2015 9:34 pm

Re: Using Sanatize Address

Wed Jan 04, 2017 10:17 pm

I'm curious - what distro do you use? I found that my Raspbian compiles and executes correctly, but I can't get that to happen with Arch Linux.

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Using Sanatize Address

Thu Jan 05, 2017 12:53 am

JovianPyx wrote:I'm curious - what distro do you use? I found that my Raspbian compiles and executes correctly, but I can't get that to happen with Arch Linux.
Raspbian, Ubuntu, and Mint.
But I install GCC myself, the latest version 6.3


JovianPyx
Posts: 121
Joined: Fri Nov 20, 2015 9:34 pm

Re: Using Sanatize Address

Wed Jan 11, 2017 8:50 pm

Thanks - that caused me to try to install gcc-libs. When I do, pacman says:

Code: Select all

error: failed to prepare transaction (could not satisfy dependencies)
:: gcc: installing gcc-libs (6.2.1-1) breaks dependency 'gcc-libs=6.1.1-1.1'
So at this point, I can't tell if it's in the package.

Oddly enough, when I try to install on Raspbian, I'm told it can't locate the package. (I tried this just to see what would happen) However, I was able to get address sanitize to work on the Raspbian installation. I must confess, that I cannot remember all of the steps it took to getting it working, it was rather messy.

EDIT ADD: I did use

Code: Select all

pkgfile -l gcc-libs
and there is no libasan within the currently installed version. I did read somewhere about it being missing, but I don't know if that was regarding 6.1.1-1.1.

Return to “Arch”