i386/119709: cc -pg produced bad binaries on x86 in 7.0-RC1

Francis Dupont Francis.Dupont at fdupont.fr
Wed Jan 16 01:00:01 PST 2008


>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 at 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:


More information about the freebsd-i386 mailing list