Bug 22886

Summary: savecore dumps core at boot
Product: Base System Reporter: Jimmy Olgeni <olgeni>
Component: binAssignee: Adrian Chadd <adrian>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Jimmy Olgeni 2000-11-16 10:30:01 UTC
The "savecore" command dumps core at boot, leaving savecore.core in the root directory.

The same problem occurs when invoked manually, I tried on 2 4.2-BETA boxes.

In both cases I didn't have a core image in swap.

How-To-Repeat: dev1# swapinfo
Device          1K-blocks     Used    Avail Capacity  Type
/dev/ad0s1b        262016        0   262016     0%    Interleaved
dev1# cat /etc/fstab | grep swa
/dev/ad0s1b             none            swap    sw              0       0
dev1# cat /etc/rc.conf |grep dumpdev
dumpdev="/dev/ad0s1b"           # Device name to crashdump to (or NO).

(it looks properly configured)

dev1# savecore /var/crash
Bus error (core dumped)
dev1# ls *core
savecore.core
dev1#
Comment 1 amorita 2000-11-16 11:33:56 UTC
I found the reason of savecore's core dump problem(PR bin/22886).

[Reason]
See compile log in src/sbin/savecore.
`ld' reports the symbol conflict `dirname'.
In savecore.c, dirname symbol is local pointer of char.
In libc/gen/dirname.c, dirname symbol is function.
--- Log
misao% make
cc -O -pipe -I/usr/SRC/src/sbin/savecore/../../usr.bin/compress   -c /usr/SRC/src/sbin/savecore/savecore.c
cc -O -pipe -I/usr/SRC/src/sbin/savecore/../../usr.bin/compress   -c /usr/SRC/src/sbin/savecore/../../usr.bin/compress/zopen.c
cc -O -pipe -I/usr/SRC/src/sbin/savecore/../../usr.bin/compress    -static -o savecore savecore.o zopen.o  
/usr/libexec/elf/ld: Warning: size of symbol `dirname' changed from 4 to 206 in dirname.o
/usr/libexec/elf/ld: Warning: type of symbol `dirname' changed from 1 to 2 in dirname.o
gzip -cn /usr/SRC/src/sbin/savecore/savecore.8 > savecore.8.gz
--- Log

[Quick Hack]
Apply below patch to src/sbin/savecore/savecore.c.
--- patch
diff -d -u -r1.28.2.3 savecore.c
--- savecore.c	2000/07/04 01:17:47	1.28.2.3
+++ savecore.c	2000/11/16 11:12:25
@@ -108,7 +108,7 @@
 int	dumpsize;			/* amount of memory dumped */
 
 char	*kernel;
-char	*dirname;			/* directory to save dumps in */
+static char	*dirname;			/* directory to save dumps in */
 char	*ddname;			/* name of dump device */
 dev_t	dumpdev;			/* dump device */
 int	dumpfd;				/* read/write descriptor on char dev */
--- patch

--
Akio Morita
Comment 2 tanimura freebsd_committer freebsd_triage 2000-11-16 11:45:32 UTC
Responsible Changed
From-To: freebsd-bugs->adrian

adrian is asking jkh for approval to fix this bug.
Comment 3 Adrian Chadd freebsd_committer freebsd_triage 2000-11-16 18:54:10 UTC
State Changed
From-To: open->closed

Fixed in rev 1.28.2.4 of src/sbin/savecore.c . 

Thanks!