Reputation: 665
I have a program which cause Seg fault in a machine, which is not accessible for me. However, when I compile and run it with the same compiler and same input on my machine, I don't get anything. The problem is probably "array index out of bound" which might lead to Seg Fault in some circumstances, however, compiler does not show any warning. The program is huge and complicated. So I cannot find the problem just by checking the code.
Any suggestion on how to get the Segmentation Fault on my machine too? This way I can debug the code and find the problem.
Upvotes: 2
Views: 860
Reputation: 134
You could use valgrind
if it works over Linux machine.
To use valgrind
you just type on console:
valgrind --leak-check=full --num-callers=20 --tool=memcheck ./program
and should return invalid read/write of size X according to the variable and (if you compiled with debugging information), it will tell you the line where the problem might be.
By the way, you can install valgrind
in Ubuntu/Debian Linux (for example) just as easy as:
sudo apt-get install valgrind
Upvotes: 6
Reputation: 64997
You can try a solution such as Valgrind as other posters mentioned, or your compiler may also have some specific ability to insert guard words before I located a raise to detect this kind of access.
Upvotes: 0