D - Hmm. Nonsensical crashing which isn't caught by catch (Error), happens
I've run into a particularly strange error. I've got this thing acting
as a webserver, and if I go into firefox and hold down the key for
refresh for 30 seconds or so, it'll crash the webserver-like-program
("D_SpaceSim.exe has encountered a problem and needs to close. blah
blah" in a dialog box.) Nothing about that was printed in the console
window for the program, etc.
So I hit debug and it VCPP6SE says "Unhandled exception in
D_SpaceSim.exe: 0xC00000005: Access Violation." and then shows me this
block of code:
------------------------------------------------------------
foreach (int i, SolarSystem ss; systems) {
if (ss!==null) {
if (ss.planets!==null) {
if (ss.sun!==null) {
s.writeString(`<li>`
~EncodeURL(
`System: planets(`~
--> .toString(ss.planets.length)
~`) coords(`~
.toString(ss.x)
~`,`~
.toString(ss.y)
~`) (Sun: `~
.toString(SunStagesStr[ss.sun.stage])
~` (Mass: `~
.toString(ss.sun.mass)
~`))`
,Pages.Galaxy,ss.uid)
~`</li>`);
} else {
Report("ss.sun is null!");
}
} else {
Report("ss.planets is null!");
}
} else {
Report("ss is null!");
}
}
------------------------------------------------------------
The --> in there is where VCPP6SE had its little yellow arrow which
marks the line that is currently being executed.
Right now, I can't think think of any reason why this should be
crashing, and I'm starting to miss the "Access Violation" errors I got
before. :P
Also, at the beginning of this function is 'synchronized(galaxy) {'
so that it can't get messed up if something else is using galaxy (The
main loop in the other thread also does synchronized(galaxy) before
doing every cycle, and does msleep(30) outside the synchronized block.
Also, I changed the code a little while ago so that it only listens to
one client thread at a time (as opposed to being able to listen to
several), so there are really only two threads, one for the web-server
and one for the rest of the program (which does stuff with planets, etc).
The crashes are always at that same point in the code, and they don't
seem to happen during normal use of the program - only when I hold down
the refresh key for a good amount of time.
Now... One last thing. Since I couldn't find this problem, I added a
try/catch(Error)/finally in doRead, around the code which calls
handleRequest, which can call various other functions, including
displayGalaxyPage, which is the function the code I quoted above is in.
-----------
protected synchronized void doRead(StreamSocket s) {
try {
blah blah blah
} catch (WriteError) {
} catch (Error) {
} finally {
try {
s.disconnect();
} catch (Error) {
}
}
}
-----------
But it doesn't seem to catch the exception/error/crashy-thing.
-SL
Mar 26 2004
"SL" <shadowlord13 users.sourceforge.net> wrote in message
news:c422jd$92j$1 digitaldaemon.com...
Now... One last thing. Since I couldn't find this problem, I added a
try/catch(Error)/finally in doRead, around the code which calls
handleRequest, which can call various other functions, including
displayGalaxyPage, which is the function the code I quoted above is in.
-----------
protected synchronized void doRead(StreamSocket s) {
try {
blah blah blah
} catch (WriteError) {
} catch (Error) {
} finally {
try {
s.disconnect();
} catch (Error) {
}
}
}
-----------
But it doesn't seem to catch the exception/error/crashy-thing.
catch (Object) should catch it.
Sep 19 2004








"Walter" <newshound digitalmars.com>