[an error occurred while processing this directive]
We start with the new source simple6.c which produces a core dump due to a Segmentation fault. Like described for gdb we can copy the core and open it in totalview:
totalview ./simple6 coreand see directly the line of code there the segmentation fault occurred.
We can dive and list values and recognize, that all values in trials look strange.
Caveat with Segmentation faults:
A segmentation fault is reported if the memory your code wants
to access is
outside the memory range given to your program. There is no complain, if
your
code modifies an adress within your memory range at an unintended place.
Anyway, there seems to be something wrong in
the loop starting at line 32 and that the array index
j exceeds the allowed range. We start totalview anew
and want to look at j at line 33. A right
mouse click on that line opens the context menu and allows us to specify
Properties.
As shown on the right, we change to Evaluate and specify a conditional breakpoint. The program should stop, when j is out of the valid range of array a. |
Of cause you have since long recognized, that the 6th element of trialsis not initialized correct.