Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Address Sanitizer Warning

For a few days now I get the following issue when starting up the Address Sanitizer within Xcode 7.3. The error messages printed to the Xcode console when the Sanitizer found an issue (that was actually suppressed by a file):

==13392==WARNING: Can't write to symbolizer at fd 55

==13392==WARNING: Can't write to symbolizer at fd 55

==13392==WARNING: Can't write to symbolizer at fd 55

==13392==WARNING: Can't write to symbolizer at fd 55

==13392==WARNING: Failed to use and restart external symbolizer!

I found the error messages in the repository but still I can't explain what's going on. Obviously the internal write function fails but I have no idea whats causing this. Any ideas?

https://github.com/Microsoft/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc#L100

like image 491
HelloWorld Avatar asked Apr 07 '16 11:04

HelloWorld


1 Answers

ASAN is missing from your path. The following was done outside Xcode to see if I could manifest the error and it was easy if the path was undefined. My guess is XCode cannot find it where it's looking or as in the following case the ASAN path is undefined.

When you try this if you add and remove it from your path the error goes away but the line numbers also disappear ie if you want to see the actual error message again you need to use

unset ASAN_SYMBOLIZER_PATH

not

ASAN_SYMBOLIZER_PATH=

Create a c program as follows...

int main(void){
    int a[3];
    a[3] = 4;
    return 0;
}

Compile it, please ignore warnings for now...

gcc -std=c11 -Wall -g3 -fno-omit-frame-pointer -fsanitize=address broken_asan_test.c
./a.out

You should see something like this...

=================================================================
==29192==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5ad1052c at pc 0x000104eefe78 bp 0x7fff5ad104f0 sp 0x7fff5ad104e8
WRITE of size 4 at 0x7fff5ad1052c thread T0
    #0 0x104eefe77 in atos[29193]: [fatal] 'pid_for_task' failed: (os/kern) failure (5) (+0x100000e77)
==29192==WARNING: Can't write to symbolizer at fd 3
    #1 0x7fff940495ac in atos[29206]: [fatal] 'pid_for_task' failed: (os/kern) failure (5) (+0x35ac)
    #2 0x0  (<unknown module>)

Notice this line

==29192==WARNING: Can't write to symbolizer at fd 3

Change to have the symbolizer added to your path...

export ASAN_SYMBOLIZER_PATH=/usr/local/Cellar/llvm/3.6.2/bin/llvm-symbolizer

and the error disappears...

=================================================================
==29312==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff55ac450c at pc 0x00010a13be78 bp 0x7fff55ac44d0 sp 0x7fff55ac44c8
WRITE of size 4 at 0x7fff55ac450c thread T0
    #0 0x10a13be77 in main (/git/ghub/doc/c/./a.out+0x100000e77)
    #1 0x7fff940495ac in start (/usr/lib/system/libdyld.dylib+0x35ac)
    #2 0x0  (<unknown module>)
like image 174
Harry Avatar answered Sep 17 '22 18:09

Harry