From aecolley@spamcop.net  Sat Jun  1 16:18:56 2002
Return-Path: <aecolley@spamcop.net>
Received: from marklar.elive.net (smtp.elive.ie [212.120.138.41])
	by hub.freebsd.org (Postfix) with ESMTP id DAAAC37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  1 Jun 2002 16:18:54 -0700 (PDT)
Received: from cornerstone.colley.ie (1Cust22.tnt2.dub2.ie.uudial.net [213.116.42.22])
	by marklar.elive.net (8.11.6/8.11.6) with ESMTP id g51N0Rv18806
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Jun 2002 00:00:33 +0100
Received: from muttley.colley.ie (muttley.colley.ie [10.0.0.2])
	by cornerstone.colley.ie (Postfix) with ESMTP id D96951EA
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  2 Jun 2002 00:15:37 +0100 (IST)
Received: by muttley.colley.ie (Postfix, from userid 1001)
	id 0EF4D1BF6; Sun,  2 Jun 2002 00:14:46 +0100 (IST)
Message-Id: <20020601231446.0EF4D1BF6@muttley.colley.ie>
Date: Sun,  2 Jun 2002 00:14:46 +0100 (IST)
From: Adrian Colley <aecolley@spamcop.net>
Reply-To: Adrian Colley <aecolley@spamcop.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] savecore fails to save core (dscheck error; unaligned read from blkdev)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         38811
>Category:       bin
>Synopsis:       [PATCH] savecore fails to save core (dscheck error; unaligned read from blkdev)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    marcel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 02 02:40:03 PDT 2002
>Closed-Date:    Sun Jun 02 12:22:57 PDT 2002
>Last-Modified:  Sun Jun 02 12:22:57 PDT 2002
>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:
Responsible-Changed-From-To: freebsd-bugs->marcel 
Responsible-Changed-By: iedowse 
Responsible-Changed-When: Sun Jun 2 03:12:36 PDT 2002 
Responsible-Changed-Why:  

Over to Marcel who made the change that caused this problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38811 
State-Changed-From-To: open->closed 
State-Changed-By: marcel 
State-Changed-When: Sun Jun 2 12:22:39 PDT 2002 
State-Changed-Why:  
Fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38811 
>Unformatted:
