Mail Archives: djgpp/1999/12/09/08:40:22
On Wed, 8 Dec 1999, Chris Underwood wrote:
> When the program crashes, it occasionally destroyes the text
> files it happens to have open, either replacing them with a series of
> repeating bytes or blanking them completely. This is strange, since the
> program only ever opens files using the following:
>
> infile = fopen(filename, "r");
>
> Note the open mode is "r", for read access only. How can a program crash
> damage files that are never written to, or even open for writing?
Bugs are sometimes very ingenious ;-) For example, your bug(s) might
be overwriting parts of memory used by your program's and causing the
files to be open in a mode other than read-only.
The best advice I can give you is to run the program under the
debugger, find the cause of the crashes and correct it. It is quite
possible that the scribbling over files will go away when you correct
that bug.
It might be a good idea to run the program in plain DOS mode, btw.
CWSDPMI, the DPMI server used on plain DOS, supports the NULL pointer
dereference protection, and so will help you catch possible bugs much
earlier than they get detected on Windows. It is possible that an
uncaught dereference of a NULL pointer does its damage before the
program crashes, and one effect of that damage is your destroyed
files.
- Raw text -