[comp.sys.amiga.tech] Does Everybody leave dos.library open?

mcmahan@netcom.UUCP (Dave Mc Mahan) (10/14/90)

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.  Upon looking
further, I find that my Manx 'C' 3.4 compiler seems to generate programs that
open the dos.library, but never seems to close it upon exit.  If most folks
where using the Manx compiler (or if Lattice did it also) I can see that this
would indeed leave open copies of dos.library around upon exit.  One would
assume that the compiler startup code would Close() anything that was Open()ed.
Is this a bug, or am I missing something?  I am in the process of ripping
apart the actual startup code that Manx links in, but my disassembler seems
to find no place where the library is closed.  Why is this?

I guess the other option is that Xoper is lying to me and there really aren't
multiple opennings of dos.library around (not very likely).


    -dave

cedman@lynx.ps.uci.edu (Carl Edman) (10/14/90)

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.Upon looking
   further,I find that my Manx 'C' 3.4 compiler seems to generate programs that
   open the dos.library, but never seems to close it upon exit.  If most folks
   where using the Manx compiler (or if Lattice did it also)I can see that this
   would indeed leave open copies of dos.library around upon exit.  One would
   assume that the compiler startup code would Close() anything that was
   Open()ed.
   Is this a bug, or am I missing something?  I am in the process of ripping
   apart the actual startup code that Manx links in, but my disassembler seems
   to find no place where the library is closed.  Why is this?

  I guess the other option is that Xoper is lying to me and there really aren't
   multiple opennings of dos.library around (not very likely).

First, all my knowledge is about DOS 1.3. I haven't programmed on the amiga
too much recently, so if anything drastic has changed in 2.0, disregard
this post.

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).

Ever noticed that no programm ever even opens much less closes
"exec.library" ? Now that is a serious problem which you should
investigate (Lots of :-) in this paragraph.)

	Carl Edman

PS: I always opened and closed not only "dos.library" but even "exec.library".
(Yes, I am a neurotic :-).


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

mcmahan@netcom.UUCP (Dave Mc Mahan) (10/15/90)

 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.

>Ever noticed that no programm ever even opens much less closes
>"exec.library" ? Now that is a serious problem which you should
>investigate (Lots of :-) in this paragraph.)

I guess it would be kind of tough to close, but it could be done.  Could be
the basis for a real neat virus if you expunged the exec.library.  :-)
>
>	Carl Edman
>
>PS: I always opened and closed not only "dos.library" but even "exec.library".
>(Yes, I am a neurotic :-).

Good to see.

    -dave

cedman@lynx.ps.uci.edu (Carl Edman) (10/15/90)

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

kris@kriski.toppoint.de (Kristian Koehntopp) (10/16/90)

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.

This is due to an error in the startup-code of Manx Aztec C Compiler, which
was present to at least version 3.6. This startup-code opened the
dos.library but did not close it automatically. I always added an appropiate
"CloseLibrary" to my programs.

Kristian

I also have to pay for incoming mail. Do not reply or keep short!

Kristian Koehntopp, Harmsstrasse 98, 2300 Kiel, +49 431 676689, kris@tpki.UUCP
Eine Nachricht dieses Absenders enthaelt 235 Bytes ASCII und 2% Header (mind.)
nach DIN. Der Bundesinformationsminister: Net-News gefaehrdet Ihre Freizeit!

rhialto@cs.kun.nl (Olaf Seibert) (10/17/90)

In article <CEDMAN.90Oct14141233@lynx.ps.uci.edu> cedman@lynx.ps.uci.edu (Carl Edman) writes:
>	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

But BadLibrary needs to expunge _itself_, so if it is really not
well behaved it doesn't even do that.

>	Carl Edman
--
Olaf 'Rhialto' Seibert                               rhialto@cs.kun.nl
How can you be so stupid if you're identical to me? -Robert Silverberg

plav@cup.portal.com (Rick M Plavnicky) (10/18/90)

In a recent article kris@kriski.toppoint.de (Kristian Koehntopp) 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,man
   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.
}
}This is due to an error in the startup-code of Manx Aztec C Compiler, which
}was present to at least version 3.6. This startup-code opened the
}dos.library but did not close it automatically. I always added an appropiate
}"CloseLibrary" to my programs.
}
}Kristian

I just looked at this in Manx 5.0d, and apparently dos.library is now
closed properly at exit time.

/* Rick Plavnicky ...!sun!cup.portal.com!plav  -or-  plav@cup.portal.com */

mcmahan@netcom.UUCP (Dave Mc Mahan) (10/18/90)

 In a previous article, kris@kriski.toppoint.de (Kristian Koehntopp) 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
>>   programs leave the dos.library open after exiting.  It seems to be
>>   a majority in the (limited) sample of stuff I tested, mostly PD.
>
>This is due to an error in the startup-code of Manx Aztec C Compiler, which
>was present to at least version 3.6. This startup-code opened the
>dos.library but did not close it automatically. I always added an appropiate
>"CloseLibrary" to my programs.

Technically, I don't think this is legal to do from within your program.  What
happens if you close the library, but the exit code produced by the compiler
(located in manx:crt_src/_main.c for the Manx compiler I have) tries to do
something with the library?  Things that come to mind are the CloseLib() calls
that Manx makes to close libraries it has opened.  Technically, if you close
the library, the program should never use it again because it may have been
flushed from memory.  To do this correctly, you would have to modify the
example _main.c source file provided by Manx and then make that your standard
startup call.  In real life, just using the dos.library even though your
program as closed it earlier is probably no big deal since several other
programs are using it at the same time so it is always open, but it is
technically not a good idea.

>Kristian


   -dave

dillon@overload.Berkeley.CA.US (Matthew Dillon) (10/20/90)

In article <CEDMAN.90Oct14141233@lynx.ps.uci.edu> cedman@lynx.ps.uci.edu (Carl Edman) writes:
>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:
>  ......... etc...



    The bug is in OLDER Lattice & Aztec startup code.  Current releases of
    Lattice and Aztec C both close the dos.library on exit.  I must say,
    though, that the way Aztec handles it is really messy.

					-Matt
--


    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA 		    -: my *second* computer is built in :-

jep@mtiame.oz (Jesper Peterson) (10/22/90)

In article <CEDMAN.90Oct13225759@lynx.ps.uci.edu> cedman@lynx.ps.uci.edu (Carl Edman) writes:
>PS: I always opened and closed not only "dos.library" but even "exec.library".
>(Yes, I am a neurotic :-).

Considering exec.library "needs" to be open before you can open it I
understand how you became neurotic.
-- 
ACSnet: jep@mtiame.mtia.oz               UUCP: ...!uunet!munnari!mtiame.oz!jep

[...] I had to leave out reality to keep the post clean and to the point.
            - jeremy@milton.u.washington.edu (Jeremy York) in rec.music.misc

cedman@lynx.ps.uci.edu (Carl Edman) (10/23/90)

In article <302@mtiame.oz> jep@mtiame.oz (Jesper Peterson) writes:
   In article <CEDMAN.90Oct13225759@lynx.ps.uci.edu> cedman@lynx.ps.uci.edu (Carl Edman) writes:
   >PS: I always opened and closed not only "dos.library" but even "exec.library".
   >(Yes, I am a neurotic :-).

   Considering exec.library "needs" to be open before you can open it I
   understand how you became neurotic.

Really ? You don't mean that the call to OpenLibrary actually is at offset
-552d from the base of exec.library and that it actually is in WOM ?

Now, please don't offend me or the readers of this group by assuming
that anyone does not know this.

The practice I described above is a sign of chronic neat-ness , not of
complete ignorance.

	Carl Edman

PS: I had hoped that my reference to reading the source to exec.library
would have spared me such answers :-).



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