-2

在测试 C 编程项目时,我遇到了这个错误:

realloc(): invalid pointer

我试图使用Valgrind找到问题的原因。当我在 Valgrind 中运行代码时,它在我的代码的不同部分陷入了无限循环,并且它没有检测到无效指针,所以我没有得到我正在寻找的答案。

我想我想知道的是:有其他人遇到过 Valgrind 的这个问题吗?出了什么问题?为什么 Valgrind 会跳入这个无限循环,但是当我自己运行代码时,我却得到了错误。

GDB 确实检测到了错误,但它给我的信息不足以修复错误;这就是为什么我想解决我在 Valgrind 中遇到的这个问题。

4

1 回答 1

0

Why does Valgrind jump into this infinite loop but when I run the code myself I just get the error.

Are you sure that it was an infinite loop? Valgrind is rather slow tool. The slowdown is about 20–30 times compared to running without Valgrind. You should probably wait for 20–30 times more to get the error under Valgrind.

于 2019-06-22T13:13:36.147 回答