-2

While testing a C programming project I encountered this error:

realloc(): invalid pointer

I tried to find the cause of the problem using Valgrind. When when I ran the code in Valgrind, it got stuck in an infinite loop in a different part of my code, and it didn't detect the invalid pointer, so I didn't get the answers I was looking for.

I guess what I want to know is: has anyone else encountered this problem with Valgrind and what's going wrong? Why does Valgrind jump into this infinite loop but when I run the code myself I just get the error.

GDB did detect the error but the info it gave me wasn't enough to fix the error; that's why I want to fix this problem I'm having with Valgrind.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
joephek09
  • 11
  • 1

1 Answers1

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.

ks1322
  • 33,961
  • 14
  • 109
  • 164