From nobody@FreeBSD.org  Tue Jul 21 21:52:25 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F41BE106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jul 2009 21:52:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id C82DA8FC20
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jul 2009 21:52:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n6LLqN2W098377
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jul 2009 21:52:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n6LLqNc5098376;
	Tue, 21 Jul 2009 21:52:23 GMT
	(envelope-from nobody)
Message-Id: <200907212152.n6LLqNc5098376@www.freebsd.org>
Date: Tue, 21 Jul 2009 21:52:23 GMT
From: Aragon Gouveia <aragon@phat.za.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] devel/ccache mmap fix for 8.0-BETA2
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         136971
>Category:       ports
>Synopsis:       [patch] devel/ccache mmap fix for 8.0-BETA2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ahze
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 21 22:00:16 UTC 2009
>Closed-Date:    Wed Aug 05 02:41:29 UTC 2009
>Last-Modified:  Wed Aug  5 02:50:01 UTC 2009
>Originator:     Aragon Gouveia
>Release:        8.0-BETA2
>Organization:
>Environment:
FreeBSD fuzz.geek.sh 8.0-BETA2 FreeBSD 8.0-BETA2 #0: Tue Jul 21 00:28:37 SAST 2009     root@fuzz.geek.sh:/usr/obj/usr/src/sys/FUZZ  amd64
>Description:
devel/ccache has a bug in its use of mmap() that reveals itself since a recent change in 8-CURRENT discussed here:

http://lists.freebsd.org/pipermail/freebsd-hackers/2009-July/029064.html

Mel Flynn later posted a ccache patch:

http://lists.freebsd.org/pipermail/freebsd-hackers/2009-July/029141.html

I've tested Mel's fix and can confirm it fixes ccache for me.  I've repackaged his work as a diff against files/patch-md4 and it's attached.

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- files/patch-md4.orig	2004-10-13 05:36:42.000000000 +0200
+++ files/patch-md4	2009-07-21 23:43:36.000000000 +0200
@@ -17,8 +17,8 @@
  
  void cc_log(const char *format, ...);
  void fatal(const char *msg);
---- hash.c.orig	Wed Sep  8 21:36:22 2004
-+++ hash.c	Wed Sep  8 21:36:25 2004
+--- hash.c.orig	2004-09-13 12:38:30.000000000 +0200
++++ hash.c	2009-07-21 23:37:00.000000000 +0200
 @@ -20,17 +20,22 @@
  */
  
@@ -46,7 +46,7 @@
  }
  
  void hash_string(const char *s)
-@@ -46,35 +51,40 @@
+@@ -46,35 +51,44 @@
  /* add contents of a file to the hash */
  void hash_file(const char *fname)
  {
@@ -72,12 +72,16 @@
 +               close(fd);
 +               fatal(__FUNCTION__);
 +       }
-+       buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 
-+       if (buf == MAP_FAILED) {
-+               cc_log("Failed to mmap %s\n", fname);
-+               close(fd);
-+               fatal(__FUNCTION__);
-+        }       
++       if( stats.st_size == 0 )
++	       buf = NULL;
++       else {
++	       buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 
++	       if (buf == MAP_FAILED) {
++		       cc_log("Failed to mmap %s\n", fname);
++		       close(fd);
++		       fatal(__FUNCTION__);
++		}       
++       }
 +
 +        hash_buffer(buf, stats.st_size);
  	close(fd);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->ahze 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Jul 21 22:00:26 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=136971 
State-Changed-From-To: open->closed  
State-Changed-By: ahze 
State-Changed-When: Wed Aug 5 02:41:17 UTC 2009 
State-Changed-Why:  
Committed, Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/136971: commit references a PR
Date: Wed,  5 Aug 2009 02:40:58 +0000 (UTC)

 ahze        2009-08-05 02:40:48 UTC
 
   FreeBSD ports repository
 
   Modified files:
     devel/ccache         Makefile 
     devel/ccache/files   patch-md4 
   Log:
   - Fix bug with mmap() on 8.x [1]
   - Remove gcc 295, 32, 33, 40, and 40 support [2]
   - Bump PORTREVISION
   
   PR:             ports/136971 [1]
                   ports/136679 [2]
   Submitted by:   Aragon Gouveia <aragon@phat.za.net> [1]
                   Ulrich Spoerlein <uqs@spoerlein.net> [2]
                   gerald [2]
   
   Revision  Changes    Path
   1.45      +2 -5      ports/devel/ccache/Makefile
   1.3       +13 -9     ports/devel/ccache/files/patch-md4
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
