10

几天来,我在 Xcode 7.3 中启动 Address Sanitizer 时遇到以下问题。当 Sanitizer 发现问题(实际上被文件抑制)时,将错误消息打印到 Xcode 控制台:

==13392==警告:无法写入 fd 55 处的符号器

==13392==警告:无法写入 fd 55 处的符号器

==13392==警告:无法写入 fd 55 处的符号器

==13392==警告:无法写入 fd 55 处的符号器

==13392==警告:无法使用和重新启动外部符号!

我在存储库中找到了错误消息,但我仍然无法解释发生了什么。显然内部写入功能失败,但我不知道是什么原因造成的。有任何想法吗?

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

4

1 回答 1

4

您的路径中缺少 ASAN。以下是在 Xcode 之外完成的,以查看我是否可以显示错误,并且如果路径未定义,这很容易。我的猜测是 XCode 找不到它正在寻找的位置,或者在以下情况下 ASAN 路径未定义。

当您尝试此操作时,如果您在路径中添加和删除它,错误就会消失,但行号也会消失,即如果您想再次看到实际的错误消息,您需要使用

unset ASAN_SYMBOLIZER_PATH

不是

ASAN_SYMBOLIZER_PATH=

创建ac程序如下...

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

编译它,请暂时忽略警告...

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

你应该看到这样的东西......

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

注意这一行

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

更改以将符号器添加到您的路径中...

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

并且错误消失了...

=================================================================
==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>)
于 2016-04-21T00:37:20.173 回答