当我编译这个简单的测试程序时,我从地址清理器中得到了明显的泄漏报告,但是当我编译同一个程序但使用无限循环并中断它时,SIGINT我没有得到任何输出。
检查 asm 输出,malloc未优化(如果可能的话)
这是地址消毒剂的预期行为吗?我在其他开发中没有遇到这个问题。
工作示例:
#include <stdlib.h>
int main(void)
{
char *a = malloc(1024);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
不工作(用 SIGINT 杀死):
#include <stdlib.h>
int main(void)
{
char *a = malloc(1024);
for(;;);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
编译: gcc test.c -o test -fsanitize=address
我在一个完整的程序中遇到了这个问题,但我把它简化为这个最小的例子。