Article View: comp.sys.amiga.tech
Article #9262Re: Need help with disapearing libraries!!
From: Kevin Clague
Date: Wed, 06 Jul 1988 16:03
Date: Wed, 06 Jul 1988 16:03
65 lines
3330 bytes
3330 bytes
[]
>In article <94Y1F20q831010pYHiE@amdahl.uts.amdahl.com> kevin@amdahl
>>What kind of programming mistakes can I make that would cause libraries
>>to be closed without CloseLibrary()'ing them explicitly?
>>Db usually indicates that the last function I've called is SPTieee(),
Thoughtfully Scott Evernden replies...
> I'll bet you that your stack isn't large enough. Bump your
> stack and see if it still happens...
> -scott
Good try, but the problem is more subtle than that. After lots of soul
searching last night, I reached true enlightenment! The GURU would be
proud. I share the solution with the net in hopes that it may help
other Amiga neophites....
The facts:
1. I use Manx 3.6.
2. Manx automaticaly opens and closes required math libraries.
Manx does this on a demand basis. On every math operation that
requires an Amiga library, manx checks the appropriate
library pointer (e.g. MathIeeeDoubBas). If it is NULL, then
Manx opens the library and sets the library pointer to
the result of OpenLibrary(), and then performs the math library
function call.
3. Manx does not print error messages or quit when it can't open
disk resident libraries (like MathIeeeDoubBas)
4. I explicitly OpenLibrary() the libs I need, so I can give the
user meaningful error messages about missing libs. Since I get
the lib open, Manx does not have to OpenLibrary() it.
5. When I'm done, I CloseLibrary() the libraries, but I don't (didn't)
set the lib pointer to NULL, so Manx's cleanup code CloseLibrary()'s
it also. The lib is now closed twice, and the lib_OpnCnt is -1.
6. The next time I run my program and open the libs, the lib_OpnCnt
is 0 which means that it can be removed by exec when the system
runs out of memory. Boom!!
Things to note:
1. Manx does not handle missing disk resident libraries well.
2. Exec does not ever check for CloseLibrary()ing too many times.
This is not a surprise.
The bug one seems very subtle, and has been around in my code for more
than a year. This is one of those bugs that can easily mess up other
program's execution. Sorry to waste net bandwidth with my specific bug,
but because it seems soooo subtle, I figured I'd share it.
-kevin
--
UUCP: kevin@amdahl.amdahl.com
or: {sun,decwrl,hplabs,pyramid,seismo,oliveb}!amdahl!kevin
DDD: 408-737-5481
USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086
[ Any thoughts or opinions which may or may not have been expressed ]
[ herein are my own. They are not necessarily those of my employer. ]
Technical Details
Message-ID:
<94VHE83H1N1010XR5XU@amdahl.uts.amdahl.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdahl!kevinReferences:
<94Y1F20q831010pYHiE@amdahl.uts.amdahl.com> <736@applix.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdahl!kevin From: kevin@amdahl.uts.amdahl.com (Kevin Clague) Newsgroups: comp.sys.amiga.tech Subject: Re: Need help with disapearing libraries!! Summary: Acheived true enlightenment!! Keywords: exec CloseLibrary() low-memory programming-error disk-resident Message-ID: <94VHE83H1N1010XR5XU@amdahl.uts.amdahl.com> Date: 6 Jul 88 16:03:38 GMT References: <94Y1F20q831010pYHiE@amdahl.uts.amdahl.com> <736@applix.UUCP> Organization: Amdahl Corporation, Sunnyvale, CA 94086 Lines: 65