From frol@nerve.riss-telecom.ru  Wed Mar 20 07:18:25 2002
Return-Path: <frol@nerve.riss-telecom.ru>
Received: from nerve.riss-telecom.ru (nerve.riss-telecom.ru [80.66.65.3])
	by hub.freebsd.org (Postfix) with ESMTP id BDF8837B400
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 20 Mar 2002 07:18:23 -0800 (PST)
Received: (from frol@localhost)
	by nerve.riss-telecom.ru (8.11.6/8.11.6) id g2KFILs49998;
	Wed, 20 Mar 2002 21:18:21 +0600 (NOVT)
	(envelope-from frol)
Message-Id: <200203201518.g2KFILs49998@nerve.riss-telecom.ru>
Date: Wed, 20 Mar 2002 21:18:21 +0600 (NOVT)
From: Dmitry Frolov <frolov@riss-telecom.ru>
Reply-To: Dmitry Frolov <frolov@riss-telecom.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: savecore -z option does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         36136
>Category:       bin
>Synopsis:       savecore -z option does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 07:20:01 PST 2002
>Closed-Date:    Wed Jan 05 09:20:41 GMT 2005
>Last-Modified:  Wed Jan 05 09:20:41 GMT 2005
>Originator:     Dmitry Frolov
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
RISS-Telecom
>Environment:
System: FreeBSD nerve.riss-telecom.ru 4.5-STABLE FreeBSD 4.5-STABLE #0: Thu Mar 7 22:35:51 NOVT 2002 root@nerve.riss-telecom.ru:/usr/src/sys/compile/NERVE i386

>Description:

	When saving kernel core dump, savecore attempts to find blocks
of zeroes in dump, and calls fseek on output stream when
finds such block. If -z option is specified, stream is created
with zlib "zopen" function, and fseek on that stream fails.

Problem represented by commit at Feb 16 2001 (savecore.c revision 1.37).

>How-To-Repeat:

# savecore -z /var/crash
savecore: reboot after panic: page fault
savecore: system went down at Wed Mar 20 19:54:18 2002
savecore: writing compressed core to /var/crash/vmcore.0.gz
savecore: /var/crash/vmcore.0.gz: Illegal seek
savecore: WARNING: vmcore may be incomplete

>Fix:

savecore.c: Don't search for zeroes if -z option is specified.

--- sbin/savecore/savecore.c.old	Wed Mar 20 21:03:18 2002
+++ sbin/savecore/savecore.c	Wed Mar 20 21:05:05 2002
@@ -432,14 +432,17 @@
 			nw = fwrite(buf, 1, nr, fp);
 		} else {
 			for (nw = 0; nw < nr; nw = he) {
-			    /* find a contiguous block of zeroes */
-			    for (hs = nw; hs < nr; hs += BLOCKSIZE) {
-				for (he = hs; he < nr && buf[he] == 0; ++he)
-				    /* nothing */ ;
-				/* is the hole long enough to matter? */
-				if (he >= hs + BLOCKSIZE)
-				    break;
-			    }
+				if (compress)
+					hs = he = nr;
+				else
+				    /* find a contiguous block of zeroes */
+				    for (hs = nw; hs < nr; hs += BLOCKSIZE) {
+					for (he = hs; he < nr && buf[he] == 0; ++he)
+					    /* nothing */ ;
+					/* is the hole long enough to matter? */
+					if (he >= hs + BLOCKSIZE)
+					    break;
+				    }
 			
 			    /* back down to a block boundary */
 			    he &= BLOCKMASK;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Wed Mar 20 10:10:08 PST 2002 
Responsible-Changed-Why:  
Des added the code for sparse dumps, so he's likely to be able 
to tell if the patch is good. It looks OK to me at a quick glance 
anyway. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36136 

From: Dmitry Frolov <frolov@riss-telecom.ru>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/36136: savecore -z option does not work
Date: Fri, 22 Mar 2002 12:27:35 +0600

 Problem doesn't exist in -current, but still in -stable.
 
 -- 
 Dmitry Frolov <frolov@riss-telecom.ru>

From: Dmitry Frolov <frolov@riss-telecom.ru>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/36136: savecore -z option does not work
Date: Fri, 22 Mar 2002 12:38:43 +0600

 Also supplied patch is not valid! I accidentially used code from
 -current, sorry. Correct way is in -current.
 
 -- 
 Dmitry Frolov <frolov@riss-telecom.ru>

From: "Dorr H. Clark" <dclark@applmath.scu.edu>
To: freebsd-gnats-submit@FreeBSD.org, frolov@riss-telecom.ru
Cc:  
Subject: Re: bin/36136: savecore -z option does not work
Date: Fri, 29 Mar 2002 11:29:56 -0800

 I found the same problem.  Here is a different patch:
 
 ***************
 *** 430,438 ****
                                   syslog(LOG_ERR, "%s: %m", ddname);
                           goto err2;
                   }
 +                 if (compress) {
 +                         nw = fwrite(buf, 1, nr, fp);
 +                 } else {
                         for (nw = 0; nw < nr; nw = he) {
                               /* find a contiguous block of zeroes */
                               for (hs = nw; hs < nr; hs += BLOCKSIZE) {
 --- 430,435 ----
 ***************
 *** 468,474 ****
                               if (he > hs)
                                       if (fseek(fp, he - hs, SEEK_CUR)
 == -1)
                                               break;
 +                       }
                   }
                   if (nw != nr) {
                           syslog(LOG_ERR, "%s: %m", path);
 --- 465,470 ----
Responsible-Changed-From-To: des->freebsd-bugs 
Responsible-Changed-By: des 
Responsible-Changed-When: Wed Apr 10 07:49:50 PDT 2002 
Responsible-Changed-Why:  
I am no longer interested in savecore. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36136 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Sun Jul 18 07:06:53 GMT 2004 
State-Changed-Why:  
Fixed in rev. 1.59 savecore/savecore.c in -CURRENT among with other changes. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36136 

From: Dmitry Frolov <frolov@riss-telecom.ru>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/36136: savecore -z option does not work
Date: Wed, 3 Nov 2004 21:26:41 +0600

 I think this PR may be closed. The problem doesn't exists
 in 5.x and nobody will want to fix it in 4.x.
 
     wbr&w, dmitry.
 -- 
 Dmitry Frolov <frolov@riss-telecom.ru>
 RISS-Telecom Network, Novosibirsk, Russia
 66415911@ICQ, +7 3832 NO WA1T, DVF-RIPE
State-Changed-From-To: patched->suspended 
State-Changed-By: linimon 
State-Changed-When: Sun Nov 7 03:32:09 GMT 2004 
State-Changed-Why:  
Submitter notes that this was never MF5ed.  Mark suspended in the off- 
chance that someone will want to do this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36136 
State-Changed-From-To: suspended->closed 
State-Changed-By: maxim 
State-Changed-When: Wed Jan 5 09:20:01 GMT 2005 
State-Changed-Why:  
Fixed in RELENG_4, thanks! 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Wed Jan 5 09:20:01 GMT 2005 
Responsible-Changed-Why:  
Feedbacks trap. 

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