Subject: Re: Debugging trouble - hw emulator?
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 08/25/2002 10:31:25
Back five days ago, I wrote

> I've got some debugging to do that's being difficult.  It's currently
> on i386, and at a certain point the machine just hard-resets, no
> dropping into ddb, nothing useful on the console (I tried using
> serial console to see), just suddenly boom, back at the BIOS splash
> screen.

and asked about hardware emulators.  I got some half-dozen responses,
for which I thank the responders (you know who you are! :-).  Before I
got any of them set up to try, though, I had a thought: I also had a
SPARC handy, and if I tried it there, maybe I'd get a panic, or
something else more informative.

I got a watchdog reset, which means it tried to take a trap while
running with traps disabled - probably something related was causing
the hard-reset on i386.

Turned out to be that I had carelessly allocated a big (slightly over
64k) buffer on the kernel stack, and in the test case in question was
using no more than the first few dozen bytes of it.  I was running off
the bottom of the stack, leaping over the redzone page (if any, I
didn't check), and smashing...*something*...below that.  I started
mallocking those buffers instead of putting them on the stack and the
crashes vanished "like a gambler's lucky streak".

I've saved the stuff about hardware emulators for future reference.  I
hope I won't have occasion to need one, but you never know.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B