jimm@amiga.UUCP (Jim Mackraz) (07/06/88)
In article <94Y1F20q831010pYHiE@amdahl.uts.amdahl.com> kevin@amdahl.uts.amdahl.com (Kevin Clague) writes:
)
)What kind of programming mistakes can I make that would cause libraries
)to be closed without CloseLibrary()'ing them explicitly? I have a
)program that opens a number of libraries including
)mathieeedoubbas.library and the ffp transcendental library.
)In very low memory situations these two libraries go away without
)me calling CloseLibrary(). I've verified this using Manx's db to
)examine the state of my program after I get a "Task Held" requester.
)Db usually indicates that the last function I've called is SPTieee(),
)and when I list the open libraries using the adl command, both the
)disk resident math libraries I mentioned are gone.
)
)Anyone have any clues as to how this may be happening? Maybe I wrote
)over some portion of each library. Does the system checksum the
)libs and verify the checksum (and possibly remove them, without a
)guru)? I could possibly be setting the lib_OpnCnt (sp?) to zero?
)I can't imagine that I could have selectively done this for both libs
)without trashing one entire lib.
)
)I can't figure out what I've done wrong. Are there any known system
)bugs in this area? Again, it occurs in VERY LOW memory situations
)(i.e. less than 40K). Any clues or help in this area would be
)greatly appreciated.
) -kevin
Here's some suggestions for checking into this problem in a structured
manner. Old tips, but maybe useful.
- In startup-sequence, loadwb -debug. This adds the 'invisible' menu
with an entry 'flushlibs.' After you think you've got the
libraries opened, do flushlibs, and this should try to expunge unopened
libraries (not all libraries expunge).
- Check the libraries open count before and after you open them.
They DO open, right?
- Printf the library base addresses returned from OpenLibrary(). When
you crash (or whenever), use wack (romwack will do) and have a look
at the memory nearby (esp. the library node). Is the open count still
reflecting your open (look at exec/libraries.i)? Is there general garbage?
- It is true, that a library will be expunged if it is not open and the
the memory is low, so if you don't really hold it open, your symptoms
could occur. Note that adl won't display libraries if their
linkage into the system library list is corrupted. This is one thing
to think about in the step above.
- Are you explicitly opening these libraries, or is the startup code of
the compiler doing it? Are you trying to 'detach?'
Good luck. Figure ways to watch the open count before, during, and after
problems.
jimm
--
Jim Mackraz, I and I Computing
amiga!jimm BIX:jmackraz
Opinions are my own. Comments regarding the Amiga operating system, and
all others, are not to be taken as Commodore official policy.
kevin@amdahl.uts.amdahl.com (Kevin Clague) (07/06/88)
[] >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. ]