Mail Archives: djgpp/1999/07/12/07:14:25
In article <19990711224517 DOT 20554 DOT 00004047 AT ng-ff1 DOT aol DOT com> you wrote:
[...]
> declared and initialized properly, and I found that changing the
> order in which the variables were declared would sometimes help (the
> error I would get is SIGSEGV, which I know is a memory-related
> error).
[...]
This behaviour change on shuffling the order of variable declarations
is a 95% certain sign of exactly one type of error: buffer overrun.
You're writing past the end (or before the beginning) of some array
variable. This ends up overwriting the contents of some *other*
variable. Reordering the variables will change which variable's value
will be garbled, and thus change behaviour from one SIGSEGV to
another, or (worse) to a silent miscalculation of results.
Examine all your variables' values carefully while running the program
in a debugger. Special attention should be paid to every kind of array
index: is it inside the bounds of that array?
For heavy-duty work of this kind, a checking tool like 'Purify' or
'Checker-gcc' would be needed. I have Checker-gcc running on Linux,
and it's really nice. Unfortunately, I don't think it is available
for DJGPP, yet.
BTW: It'd have been more useful to post a minimized, but still compilable
example source code, instead of this very verbose description.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -