From nobody@FreeBSD.org  Wed Jan 16 08:56:06 2008
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 E8B1C16A41A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 16 Jan 2008 08:56:06 +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 CD33B13C50D
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 16 Jan 2008 08:56:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0G8slxe057088
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 16 Jan 2008 08:54:47 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m0G8slF8057087;
	Wed, 16 Jan 2008 08:54:47 GMT
	(envelope-from nobody)
Message-Id: <200801160854.m0G8slF8057087@www.freebsd.org>
Date: Wed, 16 Jan 2008 08:54:47 GMT
From: Francis Dupont <Francis.Dupont@fdupont.fr>
To: freebsd-gnats-submit@FreeBSD.org
Subject: cc -pg produced bad binaries on x86 in 7.0-RC1
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         119709
>Category:       bin
>Synopsis:       gcc(1): cc -pg produced bad binaries on x86 in 7.0-RC1
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 16 09:00:00 UTC 2008
>Closed-Date:    Sun Jan 04 00:03:49 UTC 2009
>Last-Modified:  Sun Jan 04 00:03:49 UTC 2009
>Originator:     Francis Dupont
>Release:        7.0-RC1
>Organization:
ISC Inc.
>Environment:
FreeBSD f70.fdupont.fr 7.0-RC1 FreeBSD 7.0-RC1 #0: Mon Dec 24 12:18:24 UTC 2007     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
All binaries produced by [g]cc -pg crash in main() because the argument
array is not correctly copied on x86 (32 bits).
Note the bug (and its fix!) is already known for current.
>How-To-Repeat:
cat > x.c
#include <stdio.h>

int
main(int argc, char *argv[])
{
        int i;

        for (i = 0; i < argc; i++)
                printf("argv[%d] = %s\n", i, argv[i]);
        printf("...\n");
}
^D
cc -g -O -pg -o x x.c
./x
-> Segmentation fault

>Fix:
According to the current list "gprof's broken in 7-CURRENT" thread,
gcc 4.2 uses the %ecx register so it must be saved...Gdb seems to agree
and BTW it is very easy to check.

So please apply the proper patch before proposing the RC2!

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Jan 28 07:53:24 UTC 2008 
Responsible-Changed-Why:  
reclassify. 

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

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@FreeBSD.org, Francis.Dupont@fdupont.fr
Cc:  
Subject: Re: bin/119709: [gcc] cc -pg produced bad binaries on x86 in 7.0-RC1
Date: Tue, 26 Feb 2008 23:26:37 +0000

 Hi,
 
  From messages on the freebsd-current mailing list it sounds like this 
 fix should have been MFCd to RELENG_7_0.  I'm unable to reproduce this 
 issue on my amd64 machine with sources from the middle of January, but 
 while the patch mentioned on the mailing list changed 
 src/sys/i386/include/profile.h, no changes have been made to that file 
 recently; I suspect the fix was made elsewhere.  Are you able to 
 reproduce this problem with more recent sources (e.g 7.0-RC3)?
 
 Cheers,
 Bruce
State-Changed-From-To: open->feedback 
State-Changed-By: gavin 
State-Changed-When: Wed Feb 27 04:07:07 UTC 2008 
State-Changed-Why:  
Feedback has been requested 

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

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@FreeBSD.org, Francis.Dupont@fdupont.fr
Cc:  
Subject: Re: bin/119709: [gcc] cc -pg produced bad binaries on x86 in 7.0-RC1
Date: Sun, 09 Mar 2008 17:49:05 +0000

 It looks like this problem hasn't been fixed: I just tried it on a 
 7.0/i386 machine and accessing argc causes the program to segfault when 
 compiled with -pg.
 
 --
 Bruce
State-Changed-From-To: feedback->open 
State-Changed-By: brd 
State-Changed-When: Sun Mar 9 18:09:49 UTC 2008 
State-Changed-Why:  
Reopen per Bruce's email. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/119709: commit references a PR
Date: Wed, 23 Jul 2008 11:37:43 +0000 (UTC)

 luoqi       2008-07-23 11:37:20 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/i386/include     profile.h 
   Log:
   SVN rev 180756 on 2008-07-23 11:37:20Z by luoqi
   
   Unbreak cc -pg support on i386. In gcc 4.2, %ecx is used as the arg pointer
   when stack realignment is turned on (it is ALWAYS on for main), however
   in a profiling build %ecx would be clobbered by mcount(), this would lead
   to a segmentation fault when the code tries to reference any argument.
   This fix changes mcount() to preserve %ecx.
   
   PR:             bin/119709
   Reviewed by:    bde
   MFC after:      1 week
   
   Revision  Changes    Path
   1.43      +10 -1     src/sys/i386/include/profile.h
 _______________________________________________
 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"
 

From: Luoqi Chen <Luoqi.Chen@brion.com>
To: "bug-followup@FreeBSD.org" <bug-followup@FreeBSD.org>,
	"Francis.Dupont@fdupont.fr" <Francis.Dupont@fdupont.fr>
Cc:  
Subject: Re: bin/119709: [gcc] cc -pg produced bad binaries on x86 in 7.0-RC1
Date: Wed, 23 Jul 2008 04:57:45 -0700

 Sorry that I dropped the ball right before the 7.0 release: I suddenly foun=
 d myself
 very busy with my day job, and I haven't been able to find time to check in=
  the fix
 until now. The fix is in the head, I'll do an MFC to 7-stable after a week.
 
 -lq
State-Changed-From-To: open->patched  
State-Changed-By: brucec 
State-Changed-When: Wed Jul 23 21:01:33 UTC 2008 
State-Changed-Why:  
Fixed in HEAD. 

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

From: Robert Jenssen <robertjenssen@ozemail.com.au>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/119709: gcc(1): cc -pg produced bad binaries on x86 in 7.0-RC1
Date: Wed, 8 Oct 2008 10:38:10 +1100

 Any chance this will be in 7.1?
State-Changed-From-To: patched->closed 
State-Changed-By: vwe 
State-Changed-When: Sun Jan 4 00:02:44 UTC 2009 
State-Changed-Why:  
fix committed to RELENG_7 and 7.1-REL rev 183818 by kib 

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