<< Back to previous view

[PCC-353] Binaries compiled by PCC segfault in Fedora 15 Created: 27/May/11  Updated: 19/Apr/14

Status: Closed
Project: pcc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Susi Lehtola Assignee: Anders Magnusson
Resolution: Cannot Reproduce Votes: 1

File Attachments: GZip Archive compile.log.gz     File objs.tar.bz2    

 Description   
Referring to
 https://bugzilla.redhat.com/show_bug.cgi?id=708305
binaries compiled by PCC do not work in Fedora 15 (glibc 2.13.90). PCC works fine in Fedora 14 (glibc-2.13).

Example: A Hello World program (a.c)

#include <stdio.h>
int main()
{
    printf("Hello\n");
    return 0;
}

compiled with
 $ pcc a.c
and run with
 $ ./a.out

results in
 Hello
in Fedora 14 x86_64, but
 $ ./a.out
 Segmentation fault (core dumped)
in Fedora 15.

Output of $valgrind ./a.out

==4974== Process terminating with default action of signal 11 (SIGSEGV)
==4974== Access not within mapped region at address 0x0
==4974== at 0x1: ???
==4974== by 0x40042D: __do_global_ctors_aux (in /tmp/a.out)
==4974== by 0x40034D: ??? (in /tmp/a.out)
==4974== by 0xE2: ???
==4974== by 0x400554: __libc_csu_init (in /tmp/a.out)
==4974== by 0x34892213CF: (below main) (libc-start.c:185)
==4974== If you believe this happened as a result of a stack
==4974== overflow in your program's main thread (unlikely but
==4974== possible), you can try to increase the size of the
==4974== main thread stack using the --main-stacksize= flag.
==4974== The main thread stack size used in this run was 8388608.


 Comments   
Comment by Susi Lehtola [ 29/May/11 10:32 AM ]
Using the 20110529 CVS snapshot of PCC, the output of the example program is

$ ./a.out
Hello
Segmentation fault (core dumped)

Valgrind reports


==11448== Use of uninitialised value of size 8
==11448== at 0x3488E0F220: _dl_fini (dl-fini.c:217)
==11448== by 0x3489239930: __run_exit_handlers (exit.c:78)
==11448== by 0x34892399B4: exit (exit.c:100)
==11448== by 0x3489221443: (below main) (libc-start.c:258)
==11448==
==11448== Use of uninitialised value of size 8
==11448== at 0x3488E0F2CD: _dl_fini (dl-fini.c:268)
==11448== by 0x3489239930: __run_exit_handlers (exit.c:78)
==11448== by 0x34892399B4: exit (exit.c:100)
==11448== by 0x3489221443: (below main) (libc-start.c:258)
==11448==
==11448==
==11448== Process terminating with default action of signal 11 (SIGSEGV)
==11448== Bad permissions for mapped region at address 0x3488E0F3D0
==11448== at 0x3488E0F2CD: _dl_fini (dl-fini.c:268)
==11448== by 0x3489239930: __run_exit_handlers (exit.c:78)
==11448== by 0x34892399B4: exit (exit.c:100)
==11448== by 0x3489221443: (below main) (libc-start.c:258)
Comment by Gregory McGarry [ 30/May/11 04:16 AM ]
I'm guessing that you need to pull-up the csu fixes from pcc-devel.
Comment by Susi Lehtola [ 30/May/11 06:26 AM ]
No, I get the segfault with the 20110530 snapshot as well.

What do mean by csu fixes?
Comment by Gregory McGarry [ 31/May/11 07:36 AM ]
csu fixes were made to pcc-libs repository.

Which version of pcc are you using? pcc -v would tell.

Comment by Susi Lehtola [ 31/May/11 11:02 AM ]
$ pcc -v
pcc 1.1.0.DEVEL 20110530 for x86_64-unknown-linux-gnu, mockbuild@
no input files

as I stated above.
Comment by Sam Hegarty [ 15/Jun/11 06:39 AM ]
I can not reproduce this with pcc 1.1.0.DEVEL 20110612. It appears to have been resolved.
Comment by Susi Lehtola [ 15/Jun/11 09:23 AM ]
20110615 still segfaults on Fedora 15.
Comment by Sam Hegarty [ 16/Jun/11 09:10 AM ]
I'm also using Fedora 15. Did you install an updated pcc-libs along with an updated pcc?
Comment by Susi Lehtola [ 16/Jun/11 03:30 PM ]
Yes, I did.
Comment by Gregory McGarry [ 11/Jul/11 02:14 AM ]
$ uname -a
Linux fedora15 2.6.38.6-26.rc1.fc15.x86_64 #1 SMP Mon May 9 20:45:15 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
$ cat hw.c
#include <stdio.h>
int
main(void)
{
        printf("hello world\n");
        return 0;
}
$ pcc hw.c
$ ./a.out
hello world
$ ident a.out
a.out:
     $Id: crtbegin.c,v 1.7 2011/04/12 04:44:19 gmcgarry Exp $
     $Id: crtend.c,v 1.4 2011/04/12 04:44:19 gmcgarry Exp $
Comment by Susi Lehtola [ 11/Jul/11 11:20 AM ]
$ uname -r
2.6.38.8-32.fc15.x86_64
$ ./a.out
hello world
Segmentation fault (core dumped)
$ ident a.out
a.out:
     $Id: crtbegin.c,v 1.7 2011/04/12 04:44:19 gmcgarry Exp $
     $Id: crtend.c,v 1.4 2011/04/12 04:44:19 gmcgarry Exp $
Comment by Susi Lehtola [ 11/Jul/11 11:21 AM ]
PCC compilation log.
Comment by Gregory McGarry [ 01/Aug/11 02:29 AM ]
Sorry, I upgraded and still cannot reproduce this problem.

Can you compile a.c, and attach the objects and a.out to this issue?
Comment by Susi Lehtola [ 01/Aug/11 09:52 AM ]
a.o and a.out.
Comment by Anders Magnusson [ 19/Apr/14 05:27 PM ]
Just tried this on Fedora 20, with success:

localhost:/home/ragge >cat x.c
#include <stdio.h>
int main()
{
    printf("Hello\n");
    return 0;
}

localhost:/home/ragge >pcc x.c
localhost:/home/ragge >./a.out
Hello
localhost:/home/ragge >uname -a
Linux localhost.localdomain 3.13.10-200.fc20.x86_64 #1 SMP Mon Apr 14 20:34:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
localhost:/home/ragge >cat /etc/redhat-release
Fedora release 20 (Heisenbug)
Comment by Susi Lehtola [ 19/Apr/14 06:06 PM ]
As I commented in bug #420, if you compile pcc and pcc-libs with GCC at the -O2 level, you will be able to reproduce the wrong return code.
Generated at Tue Sep 02 18:54:22 CEST 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.