Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!cedman From: cedman@lynx.ps.uci.edu (Carl Edman) Newsgroups: comp.sys.amiga.tech Subject: Re: Does Everybody leave dos.library open? Message-ID: Date: 14 Oct 90 21:12:29 GMT References: <14721@netcom.UUCP> <14766@netcom.UUCP> Organization: non serviam Lines: 65 Nntp-Posting-Host: lynx.ps.uci.edu In-reply-to: mcmahan@netcom.UUCP's message of 14 Oct 90 19:38:38 GMT In article <14766@netcom.UUCP> mcmahan@netcom.UUCP (Dave Mc Mahan) writes: In a previous article, cedman@lynx.ps.uci.edu (Carl Edman) writes: >In article <14721@netcom.UUCP> mcmahan@netcom.UUCP (Dave Mc Mahan) writes: > I was just cruising through some software today, and noticed that many,many, > programs leave the dos.library open after exiting. In fact, it seems to be > a majority in the (limited) sample of stuff I tested, mostly PD. > >Yes, I have noticed that many programms do this. It is not very nice and >very clean, but in the case of "dos.library" it doesn't really matter. >There is only one copy of "dos.library" around anyway and that copy >is not in RAM but in WOM (yes, for you people out there who use these >new-fangled (:-) 500s and 2000s that is ROM). Even if you could >expunge it , it wouldn't be very likely that you would ever with a >running system get in the situation where no task anylonger needs >the dos.library. So never mind about that. It is only a matter of >tidyness (or neuroticism if you prefer). I realize that it is generally no big deal, since one would never want to expunge the dos.library, but it seems to indicate a possible problem. For those that want to leave the amiga on for weeks or months at a time and run lots of programs (we are talking about thousands if not billions of program executions) that leave dos.library open, wouldn't the variable eventually overflow and possibly cause problems. I'm messy in the rest of my life, but I try to make my programs thoughtful and tidy. Leaving a library open is not tidy. Who knows, it might cause bad effects in AmigaDos 5.3 or higher. It's just a good idea. I just checked the source to exec.library. Two points: a) The open_cnt really only is a UWORD i.e. its maximal value is 65535, a value which could possibly be reached in month long execution. b) OpenLibrary() doesn't itself do anything about open_cnt but expects the library open routine to take care of that. So it is possible that a badly written library, in conjunction with badly written program, in conjunction with veyr long running could lead to problems like this: 1. Programm BadProgram gets loaded and opens BadLibrary , but as it is a BadProgram it doesn't close it again. open_cnt stays 1 to large. 2. GoodUser leaves the computer running for months during which time BadProgramm gets loaded 65536 times. 3. As BadLibrary doesn't check for overflow it increases the open_cnt to 0 from 65535 when it is called by BadProgram again. 4. While BadProgramm still runs there is a memory crunch. All libraries are checked for expunging and BadLibrary has an open_cnt of 0 and is expunged 5. BadProgram accesses BadLibrary which is gone and ** CRASH ** ! All of this could be prevented if Exec OpenLibrary() took care of of open_cnt and other such details and checked for overflow. Why doesn't it ? Last irrelevant question: Does dos.library check for overflow ? (Not that it matters. It can't be expunged). Carl Edman Theorectial Physicist,N.:A physicist whose | Send mail existence is postulated, to make the numbers | to balance but who is never actually observed | cedman@golem.ps.uci.edu in the laboratory. | edmanc@uciph0.ps.uci.edu