我知道Valgrind以一種允許捕捉段錯誤的方式跟蹤內存。但是,爲什麼不捕獲以下段錯誤?Valgrind沒有捕捉到Segfaults
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).
該程序是否實際上分段錯誤? – Wug
運行'valgrind'的參數是? – Grambot
嗯,它確實說「應該」和「許多」,而不是「將」和「全部」:-P –