我知道Valgrind以某种方式跟踪内存,可以捕获段错误。但是,为什么它没有捕获以下的段错误?
int main() {
char *x = calloc(16, 1);
char *y = calloc(16, 1);
x[80] = 'c';
y[-80] = 'c';
printf("%c %c\n", *x, *y);
return 0;
}
难道它不能捕获堆中越界访问吗?根据Valgrind的文档:
But it should detect many errors that could crash your program (eg. cause a segmentation fault).
valgrind
? - Grambot