On 1/26/19, Eliot Moss wrote:
On 1/26/2019, Peng Yu wrote:

I have an executable. If I just run on its own, there will be
segmentation fault. But if I run it using valgrind, it finishes
successfully. Does anybody how can this happen? How to debug such a
program? Thanks.

Maybe not the sort of answer you have in mind, but I might start
with using gdb.  It should still segfault under those conditions.
You can then try recompiling to -g to get debug symbols

As Eliot says, SIGSEGV is easy.  Run under gdb until the SIGSEGV occurs,
then get a backtrace of subroutine calls, and look around.  If necessary,
then re-compile with -g to get more symbols.

On modern Intel x86_64 hardware (or on a "friendly" virtual machine) and with
lots of disk space, then try "Record and Replay":  https://rr-project.org/
(The videos are excellent!)
Re-played execution is *exactly* the same every time, so in the
worst case then binary search on the number of executed instructions
is a valid technique.

'rr' can even run the program "backwards", which is extremely useful.
Stop at the error, put a breakpoint on the entry to the current subroutine,
execute backwards to that breakpoint.  Then step forward by statement
or instruction, watching control flow, values of variables, etc.


_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to