Subject: bin/22079: savecore write 0 bytes of the dump file if physical memory is 2GB
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mhitch@lightning.msu.montana.edu>
List: netbsd-bugs
Date: 07/06/2003 20:55:05
>Number:         22079
>Category:       bin
>Synopsis:       When physical memory is 2GB, savecore will write out 0 bytes of the memory.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 07 02:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Michael L. Hitch
>Release:        NetBSD 1.6.1
>Organization:
Michael L. Hitch                        mhitch@montana.edu
Operations Consulting,  Information Technology Center
Montana State University, Bozeman, MT     USA
>Environment:
	
	
System: NetBSD netbsd2.msu.montana.edu 1.6.1 NetBSD 1.6.1 (CS20.MP) #5: Sat Jun 28 21:49:35 MDT 2003 mhitch@netbsd2.msu.montana.edu:/usr/NetBSD-1.6.1/obj/alphaev56/.alpha/sys/arch/alpha/compile/CS20.MP alpha
Architecture: alpha
Machine: alpha
>Description:
  When the size of physical memory is 2GB (and probably up to 4GB), savecore will
not write any of the physical memory out to the dump file.
>How-To-Repeat:
  On a machine with 2GB of physical memory, get a kernel crash dump written to
the swap partition.  [This after multiple hangs with power cycling the only
recourse until you finally find the hidden halt switch, then find out the swap
partition is too small, and on several hangs the SCSI driver is in a non-idle
state and can't write the dump.]

  When the system reboots and savecore runs, become puzzled when it completes
almost immediately and leave a *very* small core file.

>Fix:
  Savecore.c uses a signed int for the dumpsize, retrieving the dumpsize from the
data in the swap partition.  The dumpsize computed by the kernel is in pages, so
savecore.c multiplies by the pagesize to get the dumpsize in bytes.  When copying
from the swap partition to the core file, dumpsize is tested for > 0.  Oops.
2GB is negative in a signed 32 bit integer.

  My temporary workaround was to define dumpsize as an unsigned int, which works
for 2GB, but would fail when memory reaches 4GB, and would be incorrect for
4GB or more.

  A better fix would be to separate the dumpsize into a pages count from the
dump file and a size_t for the byte count in savecore, and use the size_t value
during the dump copy.
>Release-Note:
>Audit-Trail:
>Unformatted: