简体   繁体   English

为什么地址清理程序有时会忽略段错误?

[英]Why does address sanitizer overlook seg faults sometimes?

Been using fsanitize=address while compiling C programs, in order to track seg faults for about a year now.在编译 C 程序时一直使用fsanitize=address ,以便跟踪 seg 故障大约一年了。 Every now and then I encounter a strange behavior, my program would be seg faulting if compiled without fsanitize=address but when I compile with fsanitize=address this seg fault disappears.有时我会遇到一个奇怪的行为,如果在没有fsanitize=address的情况下编译我的程序会出现段错误,但是当我使用fsanitize=address编译时,这个段错误就会消失。 I have looked around the web but haven't been able to figure out exactly why this might be happening.我查看了 web,但无法弄清楚为什么会发生这种情况。 I know that address sanitizer is not a perfect program but just don't know exactly why it has this behavior.我知道address sanitizer程序不是一个完美的程序,但只是不知道它为什么会有这种行为。

A part of AddressSanitizer algorithm intersperses all local and global variables (and heap allocations) with 32-byte gaps to detect overflow. AddressSanitizer 算法的一部分将所有局部和全局变量(和堆分配)散布在 32 字节的间隙中以检测溢出。 Thus off-by-one overflows which used to corrupt other variables (and likely cause crashes if those variables were pointers or offsets) may no longer do this and corresponding faults will disappear.因此,用于破坏其他变量的逐一溢出(如果这些变量是指针或偏移量,可能会导致崩溃)可能不再这样做,相应的故障将消失。

Asan should still report errors for such overflows which apparently it does not in your case. Asan 仍应报告此类溢出的错误,这显然不适用于您的情况。 This may be uncovering some issue in Asan or (more likely) the way you run it (eg not combining it with -U_FORTIFY_SOURCE or -fno-common as explained in FAQ )这可能会发现 Asan 中的某些问题或(更有可能)您运行它的方式(例如,未将其与-U_FORTIFY_SOURCE-fno-common结合使用,如 常见问题解答中所述)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM