Subject: Re: kernel stack overflow on netbsd-1-6 branch
To: David Laight <david@l8s.co.uk>
From: SAITOH Masanobu <masanobu@iij.ad.jp>
List: port-i386
Date: 11/26/2002 20:23:55
 > >  Following patches pullup the KSTACK_CHECK_DR0 functions into netbsd-1-6
 > > branch. You may see "trap on DR0: maybe kernel stack overflow" message
 > > at boot time or heavy load.
 > > 
 > >  Should we increase UPAGES or am I misunderstanding something?
 > 
 > Better to look at the traceback and find which routine is responsible
 > for the excessive stack use.
 > 
 > 	David

trace output:

---------------------------------------
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs
panic: trap on DR0: maybe kernel stack overflow

Stopped in pid 1 (init) at      cpu_Debugger+0x4:       leave
db> trace
cpu_Debugger(c106cb00,e325a000,5,0,0) at cpu_Debugger+0x4
32: panic(c0506380,0,0,0,c106cb00) at panic+0xad
80: trap() at trap+0x185
--- trap (number 5) ---
152: pmap_extract(c06487e0,c106cb00,c8f12000,2000,0) at pmap_extract+0x1
80: _bus_dmamap_load(c06487e0,c106cb00,c8f12000,2000,0,109,6,0) at _bus_dmamap_load+0x4f
64: ahc_setup_data(c103e000,c10d6000,c1068488,0,c10d6000) at ahc_setup_data+0x8f
144: ahc_action(c103e02c,0,c10d6000,0) at ahc_action+0x41d
48: scsipi_run_queue(c103e02c,3fff0699,e32595dc,c037883b) at scsipi_run_queue+0x1ab
64: scsipi_execute_xs(c10d6000,e32596b8,6,0,21009) at scsipi_execute_xs+0x1f0
48: scsi_scsipi_cmd(c106c500,e32596b8,6,c8f12000,2000) at scsi_scsipi_cmd+0xcf
80: scsipi_command(c106c500,e32596b8,6,c8f12000,2000) at scsipi_command+0x68
112: sdstart(c106c500,c10ca400,e325971c,c0383209,c10ca4b4,c10f8000,0,c035d53d) at sdstart+0x225
80: sdstrategy(c10f8000,2000,e325975c,c025d073,c10f8000) at sdstrategy+0x1c7
48: spec_strategy(e32597a4,2,e325979c,c02b137a,c10f8000) at spec_strategy+0x50
48: ufs_strategy(e32597a4,e3257850,0,e3259898,e325989c) at ufs_strategy+0xb7
48: VOP_STRATEGY(c10f8000,1,0,e32598ac) at VOP_STRATEGY+0x2b
336: genfs_getpages(e3259964,c10d6000,2fff0699,c106c500,e3259a18) at genfs_getpages+0xc47
48: ffs_getpages(e3259964,0,c1068488,c103e000,8) at ffs_getpages+0x75
96: VOP_GETPAGES(e3257850,0,0,e32599d4,e3259a18,0,1,0,402,8,c10d7000,c0358e95,e32599d4,0,8,ca29f578) at VOP_GETPAGES+0x5e
144: ubc_fault(e3259b20,e2a57000,e3259aa0,1,0,0,1,402) at ubc_fault+0x14c
288: uvm_fault(c0664520,e2a57000,0,1,4c) at uvm_fault+0x567
80: trap() at trap+0x4f0
--- trap (number 6) ---
128: kcopy(e2a57000,4c,e3259d0c,194,e3257850) at kcopy+0x2f
128: ffs_read(e3259cb8,30001,e3259ccc,c02b0ac9,0) at ffs_read+0x112
64: VOP_READ(e3257850,e3259d0c,0,c0f3af00,0) at VOP_READ+0x3b
96: vn_rdwr(0,e3257850,c10ef700,4c,0) at vn_rdwr+0x83
96: check_exec(e325a000,e3259eb4,0,e3259e20,bfbfdff5) at check_exec+0x11b
400: sys_execve(e325a000,e3259f80,e3259f70,0) at sys_execve+0xe4
112: start_init(e325a000) at start_init+0x1c5
---------------------------------------

small patch via yamt

Index: db_trace.c
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/arch/i386/i386/db_trace.c,v
retrieving revision 1.35
diff -u -p -r1.35 db_trace.c
--- db_trace.c	2002/11/22 15:23:39	1.35
+++ db_trace.c	2002/11/26 10:53:02
@@ -441,6 +441,8 @@ db_stack_trace_print(db_expr_t addr, boo
 				narg = db_numargs(frame);
 		}
 
+		if (lastframe != 0)
+			(*pr)("%lu: ", (long)frame - (long)lastframe);
 		(*pr)("%s(", name);
 
 		if (lastframe == 0 && offset == 0 && !have_addr) {

----------------------------------------------------------
		SAITOH Masanobu (masanobu@iij.ad.jp
				  msaitoh@netbsd.org)