Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting out of array access violation

I've modified the small part of a simulator but I've faced to strange segmentation fault. GDB shows the error is appear from a class where I've not modified. I guess my code has memory access violation upon accessing its own array which accordingly destroys the content of other array (allocated in the program memory space). Is there any debugging tool to detect out-of-array-bound but inside-the-program-space accesses?

like image 975
lashgar Avatar asked Dec 02 '25 06:12

lashgar


2 Answers

In short, Valgrind will do this. Just run it as valgrind /path/to/executable

like image 61
slugonamission Avatar answered Dec 03 '25 20:12

slugonamission


You are looking for valgrind.

It is available as a package on at least most linux distributions, and will detect memory access.

Just start the program with valgrind:

valgrind ./program

like image 43
perh Avatar answered Dec 03 '25 21:12

perh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!