PDA

View Full Version : Crashing when quitting


imported_Nickolei
2002.07.05, 01:54 PM
A bug just creeped into a program of mine that is beyond my limited experience. When quitting my program it sometimes "crashes" This is with Codewarrior 7 Pro and MSL_ALL_Carbon.Lib/MSL_ALL_Carbon_D.Lib

OS X

-Debugger Target (Debug Off): Quits Fine, system message "The Application... has unexpectedly quit"
-Debugger Target (Debug On): Sometimes jumps to debugger and idles indefinitely
-Non Debugger Target: Quits Fine, no messages


OS 9

-Debugger Target (Debug Off): "PowerPC Illegal instruction" in MacBugs
-Debugger Target (Debug On): __destroy_global_chain is on stack, "illegal instruction exception"
-Non Debugger Target: Quits Fine, no messages

It seems to be not a major problem since I'm not distributing a debugger version obviously, but it is a major annoyance. Any ideas?

inio
2002.07.05, 03:30 PM
Originally posted by Nickolei
OS 9
-Debugger Target (Debug On): __destroy_global_chain is on stack, "illegal instruction exception"

My spidey sense is tingling. Whats the exact stack trace?

imported_Nickolei
2002.07.06, 01:01 PM
On os 9 the entire Stack is

__start
exit
__destroy_global_chain
std:basic__filebuf<wchar__t,std:char__traits<wchar_t>>::seekpos(std::fpos<int>,std::ios_base::openmode)

[last two lines are one item]

On os X it still hangs up but I know it hasn't always done that.

Is this something I did or something wrong with MSL?

imported_Nickolei
2002.07.06, 01:04 PM
Um that :o should be a ":" and a "o" as in ": openmode"

crazyness

:cool:

inio
2002.07.06, 01:34 PM
darn, not what I was hoping. I can't help you much other than saying the problem might be related to some ofile (or ifile) you leave open. No clue beond that.

jefftkd
2002.07.09, 02:12 PM
In my experience, almost every single crash at quitting time has to do with memory deallocation -- you are trying to delete (free) a resource/object/pointer, etc. that has already been deleted.

Set a break point and run in debug mode -- I'm sure you'll find it :).

Jeff :cool:

imported_Nickolei
2002.07.09, 10:59 PM
Thanks for the replies...they really do help..

I did try stepping through in the debugger...but everything worked until it ran out of my files and started with (I assume Metrowerk's) exiting code...which it didn't have the source files for so I was stepping through assembler...which I have no ability to discern.

The bug does seem to have disappeared though. I just kept working on other stuff and it disappeared just as naturally.

Kinda scary in a way. My mac usually holds me in a state of delightful disillusionment. I think I'll just catagorize this with UFOs.

:cool:

Padraic

a.k.a. Nickolei

frac707
2005.02.14, 09:20 PM
I've got the same kind of problem now, but it's not going away. The crash occurs when I link to an external function (one in another file in the project.) Even if the function is never acessed just having it accessible causes the linker to add that code to the executable, and that causes the problem. If I comment out the function there are no crashes, so I can't see how memory deallocation is the issue, unless it is an internal compiler or library bug. I am linking to MSL_ALL_Carbon.Lib with CW 9.4. The debugger says "access exception fault" , which certainly looks like memory is being deallocated that's already been freed. But how come it only happens when an "unused" function is linked to? Note: The function is an important option in the program, so I can't just dispose of it.