delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/09/08:40:22

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Corruption of read-only files on program crash
Date: Thu, 9 Dec 1999 11:36:41 +0200
Organization: NetVision Israel
Lines: 29
Message-ID: <Pine.SUN.3.91.991209113620.21000N-100000@is>
References: <82l8ll$4h2 AT romeo DOT logica DOT co DOT uk>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 944732104 15168 199.203.121.2 (9 Dec 1999 09:35:04 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 9 Dec 1999 09:35:04 GMT
X-Sender: eliz AT is
In-Reply-To: <82l8ll$4h2@romeo.logica.co.uk>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019