Address Sanitizer Warning
Asked Answered
R

1

11

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

Rumph answered 7/4, 2016 at 11:51 Comment(1)
Btw, the same works fine in Xcode 7.2.1. Tending to think it's a bug in Xcode 7.3Rumph
B
5

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>)
Bluestone answered 21/4, 2016 at 0:37 Comment(2)
Thanks. As you mentioned, the problem is caused by the missing path. It seems that the command line tools for xcode 7.3 are broken. I reported it to Apple. Switchting it back to Xcode 7.2.1 (through the options dialog of Xcode) in Xcode 7.3 makes it work again. Rebuild needed though.Rumph
I assume that if I ignore this then the only drawback is the missing address sanitizer check?Shaver

© 2022 - 2024 — McMap. All rights reserved.