From owner-freebsd-bugs Sun Jun 2 2:42:12 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 7CC1037B411 for ; Sun, 2 Jun 2002 02:40:05 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g529e4v56900; Sun, 2 Jun 2002 02:40:04 -0700 (PDT) (envelope-from gnats) Received: from marklar.elive.net (smtp.elive.ie [212.120.138.41]) by hub.freebsd.org (Postfix) with ESMTP id DAAAC37B400 for ; 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 ; 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 ; 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 Reply-To: Adrian Colley To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/38811: [PATCH] savecore fails to save core (dscheck error; unaligned read from blkdev) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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