Date: Sun, 2 Jun 2002 00:14:46 +0100 (IST) From: Adrian Colley <aecolley@spamcop.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/38811: [PATCH] savecore fails to save core (dscheck error; unaligned read from blkdev) Message-ID: <20020601231446.0EF4D1BF6@muttley.colley.ie>
next in thread | raw e-mail | index | archive | help
>Number: 38811
>Category: bin
>Synopsis: [PATCH] savecore fails to save core (dscheck error; unaligned read from blkdev)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Jun 02 02:40:03 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Adrian Colley
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
dis
>Environment:
System: FreeBSD muttley.colley.ie 5.0-CURRENT FreeBSD 5.0-CURRENT #5: Fri Apr 26 18:52:10 IST 2002 aecolley@muttley.colley.ie:/c/usr.obj/usr/src/sys/MUTTLEY i386
>Description:
savecore produces an "Invalid argument" error when reading the dump device, and
"dscheck(ad1s4b): bio_bcount 4 is not on a sector boundary (ssize 512)" is
printf'd on console.
>How-To-Repeat:
Panic and dump. savecore -v /var/crash
>Fix:
This bug was introduced in rev 1.61 of savecore.c, when a buffer was changed from
stack-allocated-array to pointer-to-heap-allocated-array, and so sizeof(buf)
suddenly changed from 1048576 to 4. (That's C for you.)
--- srcpatch-savecore begins here ---
Index: src/sbin/savecore/savecore.c
===================================================================
RCS file: /b/cvs/src/sbin/savecore/savecore.c,v
retrieving revision 1.61
diff -u -r1.61 savecore.c
--- src/sbin/savecore/savecore.c 27 May 2002 07:54:43 -0000 1.61
+++ src/sbin/savecore/savecore.c 1 Jun 2002 22:40:53 -0000
@@ -225,7 +225,8 @@
* this by doing a on-time allocation...
*/
if (buf == NULL) {
- buf = malloc(1024 * 1024);
+#define SIZEOFBUF (1024 * 1024)
+ buf = malloc(SIZEOFBUF);
if (buf == NULL) {
syslog(LOG_ERR, "%m");
return;
@@ -371,7 +372,7 @@
compress ? "compressed " : "", buf);
while (dumpsize > 0) {
- wl = sizeof(buf);
+ wl = SIZEOFBUF;
if (wl > dumpsize)
wl = dumpsize;
nr = read(fd, buf, wl);
--- srcpatch-savecore ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020601231446.0EF4D1BF6>
