Issue Details (XML | Word | Printable)

Key: PCC-398
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Anders Magnusson
Reporter: Roland Mainz
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
pcc

"hello world" build with pcc-libs-1.0.1.BETA-20120809+pcc-1.0.1.BETA-20120809 on SuSE 12.1 crashes...

Created: 09/Aug/12 12:13 PM   Updated: 02/May/14 12:24 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File fix_sections.diff (1 kB)

Environment: SuSE 12.1


 Description  « Hide
SuSE Linux 12.1 (with latest updates)
Compiled pcc-libs-1.0.1.BETA-20120809+pcc-1.0.1.BETA-20120809 with $ ./configure --prefix=$HOME/pcc 2>&1 | tee -a buildlog.log # ... the build and installation work... but when I compile&&run a simple "hello world" like this one...
-- snip --
#include <stdlib.h>
#include <stdio.h>

int main(int ac, char *av[])
{
        puts("hello world chicken monster");
        return EXIT_SUCCESS;
}
-- snip --
... it crashes like this:
-- snip --
$ gdb ./a.out
GNU gdb (GDB) SUSE (7.3-41.1.2)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/test001/work/pcc/tmp/a.out...done.
(gdb) run
Starting program: /home/test001/work/pcc/tmp/a.out
Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
Missing separate debuginfo for /lib64/libc.so.6

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000001 in ?? ()
(gdb) where
#0 0x0000000000000001 in ?? ()
#1 0x00000000004004a1 in __ctors ()
#2 0x000000000040050e in __do_global_ctors_aux ()
#3 0x00000000004003a8 in _init ()
#4 0x00007fffffffe258 in ?? ()
#5 0x00000000004005c5 in __libc_csu_init (argc=1, argv=0x7fffffffe248, envp=0x7fffffffe258) at elf-init.c:120
#6 0x00007ffff7a6d1d0 in __libc_start_main () from /lib64/libc.so.6
#7 0x0000000000400409 in _start () at ../sysdeps/x86_64/elf/start.S:113
-- snip --

Any quick help or (dirty/magically/etc.) workaround would be very appreciated (I want to verify PCC-389 and then integrate pcc into the AT&T regression test toolchain) ...


 All   Comments   Change History      Sort Order: Descending order - Click to sort in ascending order
Anders Magnusson added a comment - 02/May/14 12:24 PM
current of both pcc and pcc-libs.

Roland Mainz added a comment - 01/May/14 11:06 PM
Which source version should I checkout to verify the fix ?

Anders Magnusson added a comment - 30/Apr/14 10:12 PM
Tested example on openSuSE 13.1 without any problems at all.


Anders Magnusson added a comment - 19/Apr/14 06:00 PM
Is there a free version of SuSe that I can install and test on?

Simon Nicolussi added a comment - 05/Oct/12 07:16 PM
I was seeing the same symptoms in Slackware 13.37 with PCC 1.0.0. Applying this patch from CVS rectified the issue.

Roland Mainz added a comment - 10/Aug/12 08:17 PM
Note that pcc configured to create 32bit binaries on SuSE Linux 12.2 has the same problem.

I've used the following script to build "pcc" for 32bit executables:
-- snip --
#!/usr/bin/ksh93

#
# build Linux/i386/32bit version of pcc on Linux/AMD64
#

# create a wrapper script
function printf_wrappercmd
{
typeset cmd="$1"
shift
{
printf '#!/usr/bin/ksh\n'
printf "$@"
} >"${cmd}"
chmod a+rx "${cmd}"
return 0
}

set -o xtrace
set -o errexit

builtin chmod
builtin mkdir
builtin rm

# configuration data
compound -r config=(
tmpbin="${PWD}/bin"
pccinstallationdir="$HOME/pcc"
)

#
# create wrapper scripts
#
mkdir -p "${config.tmpbin}"
printf_wrappercmd "${config.tmpbin}/gccm32" "%s\n" 'gcc -m32 "$@"'
printf_wrappercmd "${config.tmpbin}/ld_b_elf_i386" "%s\n" 'ld -m elf_i386 "$@"'
printf_wrappercmd "${config.tmpbin}/as32" "%s\n" 'as --32 "$@"'

rm -Rf "${pccinstallationdir}"
rm -Rf 'pcc-libs-1.0.1.BETA'
rm -Rf 'pcc-1.0.1.BETA'

gunzip -c <'./pcc-1.0.1.BETA-20120809.tgz' | pax -r
gunzip -c <'./pcc-libs-1.0.1.BETA-20120809.tgz' | pax -r

export PATH="${config.tmpbin}:${PATH}"

#
# build pcc-libs
#
{
cd 'pcc-libs-1.0.1.BETA'

CC="${config.tmpbin}/gccm32" /usr/bin/ksh ./configure \
"--prefix=${config.pccinstallationdir}" \
--build=i386-pc-linux-gnu \
--host=i386-pc-linux-gnu \
--target=i386-pc-linux-gnu

make

make install

cd ..
} 2>&1 | tee -a buildlog.log

#
# build pcc itself
#
{
cd 'pcc-1.0.1.BETA'

CC="${config.tmpbin}/gccm32" /usr/bin/ksh ./configure \
"--prefix=${config.pccinstallationdir}" \
--build=i386-pc-linux-gnu \
--host=i386-pc-linux-gnu \
--target=i386-pc-linux-gnu \
"--with-assembler=${config.tmpbin}/as32" \
"--with-linker=${config.tmpbin}/ld_b_elf_i386"

make

make install

cd ..
} 2>&1 | tee -a buildlog.log

export PATH="${config.pccinstallationdir}/bin:$PATH"
[[ -x "${config.pccinstallationdir}/bin/pcc" ]] || { print -u2 'pcc not found.' ; exit 1 ; }

#
# run compiler test
#
cat >'x.c' <<EOF
#include <stdlib.h>
#include <stdio.h>

int main(int ac, char *av[])
{
        puts("hello world chicken");
        return EXIT_SUCCESS;
}
EOF

pcc x.c -o './x'

ldd './x'

printf $"# test begin\n"
./x || true
printf $"# test end\n"

exit 0
# EOF.
-- snip --

The resulting binary "x" still crashes like this:
-- snip --
(gdb) where
#0 0x00000001 in ?? ()
#1 0x08048378 in __do_global_ctors_aux ()
#2 0x080482b8 in _init ()
#3 0xf7ffd8e8 in _r_debug ()
#4 0x08049ff4 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
-- snip --