Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jan 2008 08:54:47 GMT
From:      Francis Dupont <Francis.Dupont@fdupont.fr>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/119709: cc -pg produced bad binaries on x86 in 7.0-RC1
Message-ID:  <200801160854.m0G8slF8057087@www.freebsd.org>
Resent-Message-ID: <200801160900.m0G900wk043436@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         119709
>Category:       i386
>Synopsis:       cc -pg produced bad binaries on x86 in 7.0-RC1
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 16 09:00:00 UTC 2008
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801160854.m0G8slF8057087>