Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 390425 - dev-libs/mpfr-3.1.0: tests fail on freebsd and causes >=sys-devel/gcc-4.3 to segfaults with math builtins
Summary: dev-libs/mpfr-3.1.0: tests fail on freebsd and causes >=sys-devel/gcc-4.3 to ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: AMD64 FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-13 17:43 UTC by Tibor Vago
Modified: 2012-05-07 13:05 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
verbose compile log for faulty target (test-cc1.log,7.35 KB, text/plain)
2011-11-27 19:12 UTC, Tibor Vago
Details
mpfr-3.1.0 build log (build.log,553.32 KB, text/plain)
2011-11-29 13:42 UTC, Tibor Vago
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tibor Vago 2011-11-13 17:43:20 UTC
lenovo ~ # cat gcc-log.c 
#include <stdio.h>
#include <math.h>

int main() {
        log(2);
}
lenovo ~ # gcc-4.2.4 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.3.6 -c -o gcc-log.o gcc-log.c
gcc-log.c: In function 'main':
gcc-log.c:7: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.
lenovo ~ # gcc-4.4.6 -c -o gcc-log.o gcc-log.c
gcc-log.c: In function 'main':
gcc-log.c:7: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.
lenovo ~ # gcc-4.5.3 -c -o gcc-log.o gcc-log.c
gcc-log.c: In function 'main':
gcc-log.c:7:2: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.



lenovo ~ # cat gcc-log.c 
#include <stdio.h>
#include <math.h>

int main() {
        int two = 2;
        log(two);
}
lenovo ~ # gcc-4.2.4 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.3.6 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.4.6 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.5.3 -c -o gcc-log.o gcc-log.c



lenovo ~ # cat gcc-log.c 
#include <stdio.h>
#include <math.h>

int main() {
        log(2);
}
lenovo ~ # gcc-4.2.4 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.3.6 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.4.6 -c -o gcc-log.o gcc-log.c
lenovo ~ # gcc-4.5.3 -c -o gcc-log.o gcc-log.c
Comment 1 Tibor Vago 2011-11-13 17:45:06 UTC
lenovo ~ # emerge --info
Portage 2.2.0_alpha74 (default/bsd/fbsd/amd64/8.2, gcc-4.5.3, freebsd-lib-8.2-r1, 8.2-RELEASE amd64)
=================================================================
System uname: FreeBSD-8.2-RELEASE-amd64-64bit-ELF
Timestamp of tree: Sun, 13 Nov 2011 10:30:01 +0000
app-shells/bash:         4.2_p10
dev-lang/python:         2.7.2-r3, 3.2.2
dev-util/pkgconfig:      0.26
sys-apps/baselayout:     2.1
sys-apps/openrc:         0.9.4
sys-devel/autoconf:      2.68
sys-devel/automake:      1.9.6-r3, 1.11.1-r1
sys-devel/binutils:      2.20.1-r1
sys-devel/gcc:           4.2.4-r1, 4.3.6-r1, 4.4.6-r1, 4.5.3-r1
sys-devel/gcc-config:    1.5-r2
sys-devel/libtool:       2.4-r4
sys-devel/make:          3.82-r3
sys-freebsd/freebsd-lib: 8.2-r1 (virtual/os-headers)
Repositories: gentoo gentoo-fbsd
Installed sets: 
ACCEPT_KEYWORDS="amd64-fbsd x86-fbsd ~amd64-fbsd ~x86-fbsd"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-gentoo-freebsd8.2"
CFLAGS="-w -O2 -march=native -pipe"
CHOST="x86_64-gentoo-freebsd8.2"
CONFIG_PROTECT="/etc /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-w -O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs chflags distlocks ebuild-locks fixlafiles news parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://ftp.fsn.hu/pub/linux/distributions/gentoo/"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--allow-multiple-definition"
LINGUAS="hu"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X amd64-fbsd apng bzip2 cli cracklib crypt cxx dbus dri gif gmp iconv ipv6 java5 java6 jpeg kde lzma mmx modules multilib ncurses nopie nossp nptlonly ogg opengl optimization oss pcre png qt3support qt4 session sse sse2 sse3 sse4 sse4_1 ssl ssse3 strong-optimization symlink tcpd tftp threads tiff unicode usb vlc vorbis wimax wps xorg zfs zlib" CAMERAS="ptp2" ELIBC="FreeBSD" INPUT_DEVICES="keyboard mouse" KERNEL="FreeBSD" LINGUAS="hu" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="BSD" VIDEO_CARDS="nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Tibor Vago 2011-11-13 17:49:14 UTC
Sorry, in the comment#1 the third C file is:

lenovo ~ # cat gcc-log.c 
#include <stdio.h>
#include <math.h>

int main() {
        log(1);
}
lenovo ~ #

Interesting when log(1) and log(variable) is compile without error while log(2) segfaults gcc.
Comment 3 Tibor Vago 2011-11-13 18:07:53 UTC
Hmmm, not comment#1 but Description field.
Comment 4 Tibor Vago 2011-11-13 19:21:36 UTC
This is also segfaults >=gcc-4.3:

#include <stdio.h>
#include <math.h>

int main() {
        pow(12.0,2.0);
}



If the base is 2, 4, 8, 16...2^x then not segfaults gcc:

#include <stdio.h>
#include <math.h>

int main() {
        pow(16.0,2.0);
}



Next example not segfaults gcc too:

#include <stdio.h>
#include <math.h>

int main() {
        int base = 12;
        int ex = 2;
        pow(base,ex);
}
Comment 5 Tibor Vago 2011-11-13 19:30:32 UTC
int one = 1;
exp(one); // not segfaults gcc
exp(0);   // not segfaults gcc
exp(1);   // segfaults gcc
Comment 6 Tibor Vago 2011-11-14 16:33:35 UTC
$ gcc -v
Using built-in specs.
Target: x86_64-gentoo-freebsd8.2
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.4-r1/work/gcc-4.2.4/configure --prefix=/usr --bindir=/usr/x86_64-gentoo-freebsd8.2/gcc-bin/4.2.4 --includedir=/usr/lib/gcc/x86_64-gentoo-freebsd8.2/4.2.4/include --datadir=/usr/share/gcc-data/x86_64-gentoo-freebsd8.2/4.2.4 --mandir=/usr/share/gcc-data/x86_64-gentoo-freebsd8.2/4.2.4/man --infodir=/usr/share/gcc-data/x86_64-gentoo-freebsd8.2/4.2.4/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-gentoo-freebsd8.2/4.2.4/include/g++-v4 --host=x86_64-gentoo-freebsd8.2 --build=x86_64-gentoo-freebsd8.2 --disable-altivec --disable-nls --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --disable-libmudflap --disable-libssp --disable-libgomp --enable-checking=release --disable-libgcj --enable-languages=c,c++,treelang --enable-shared --enable-threads=posix --enable-__cxa_atexit
Thread model: posix
gcc version 4.2.4 (Gentoo 4.2.4-r1 p1.1)

Installed gcc versions: 4.2.4-r1 (00:32:06 11/10/11) USE: (multilib -altivec -bootstrap -build -doc -fortran -gcj -gtk -hardened -libffi -mudflap -multislot -nls -nocxx -nptl -objc -objc++ -objc-gc -openmp -test -vanilla)
Comment 7 Tibor Vago 2011-11-14 22:15:15 UTC
Can anyone try this on x86_64-gentoo-freebsd8.0? My first tip is the problem is in freebsd-lib-8.2. When I compile that some multiple definitions error are occured under linking.
Comment 8 Naohiro Aota gentoo-dev 2011-11-20 04:58:29 UTC
I had the same problem with Gentoo/FreeBSD 8.2
but now it vanished...:(

toolchain team, any idea or suggestions?
Comment 9 SpanKY gentoo-dev 2011-11-20 06:05:32 UTC
try using -fno-builtin.  if that doesn't crash, try this simple code:

$ cat test.c
#include <gmp.h>
#include <mpfr.h>
main(){
mpfr_t t;
mpfr_init2 (t, 200);
mpfr_set_d (t, 1.0, GMP_RNDD);
return mpfr_log (t, t, GMP_RNDD);
}
$ gcc test.c -lmpfr && ./a.out
Comment 10 Tibor Vago 2011-11-20 11:52:36 UTC
-fno-builtin works. GCC didn't crashed. The simple mpfr code was works fine too with all GCC versions.
Comment 11 Tibor Vago 2011-11-20 22:10:05 UTC
I was recompiled the whole system with "-fno-builtin" without error.
What next?
Comment 12 SpanKY gentoo-dev 2011-11-22 22:11:25 UTC
building the system with -fno-builtin is a bad idea.  that isn't a fix.  it's a good data thing to know, but that's it.

someone who has a crashy gcc has to debug it and find out why.  the first step is to get gcc crashing again.  then run it through gdb:
  gdb --args gcc -c gcc-log.c
Comment 13 Tibor Vago 2011-11-24 12:09:59 UTC
I don't know how could I debug it. I never used gdb. The second thing is emerge strip the binaries and libraries. How can I prevent emerge to strip gcc?
Comment 15 Tibor Vago 2011-11-26 11:44:11 UTC
Ok, lets see:

lenovo ~ # file /usr/x86_64-gentoo-freebsd8.2/gcc-bin/4.6.2/x86_64-gentoo-freebsd8.2-gcc
/usr/x86_64-gentoo-freebsd8.2/gcc-bin/4.6.2/x86_64-gentoo-freebsd8.2-gcc: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, not stripped
lenovo ~ # emerge --info =gcc-4.6.2
Portage 2.2.0_alpha77 (default/bsd/fbsd/amd64/8.2, gcc-4.6.2, freebsd-lib-8.2-r1, 8.2-RELEASE amd64)
=================================================================
                        System Settings
=================================================================
System uname: FreeBSD-8.2-RELEASE-amd64-64bit-ELF
Timestamp of tree: Sat, 26 Nov 2011 11:00:01 +0000
app-shells/bash:         4.2_p20
dev-lang/python:         2.7.2-r3, 3.2.2
dev-util/cmake:          2.8.6-r3
dev-util/pkgconfig:      0.26
sys-apps/baselayout:     2.1
sys-apps/openrc:         0.9.4
sys-devel/autoconf:      2.13, 2.68
sys-devel/automake:      1.9.6-r3, 1.11.1-r1
sys-devel/binutils:      2.20.1-r1
sys-devel/gcc:           4.2.4-r1, 4.5.3-r1, 4.6.2
sys-devel/gcc-config:    1.5-r2
sys-devel/libtool:       2.4.2
sys-devel/make:          3.82-r3
sys-freebsd/freebsd-lib: 8.2-r1 (virtual/os-headers)
Repositories: gentoo gentoo-fbsd
Installed sets: 
ACCEPT_KEYWORDS="amd64-fbsd x86-fbsd ~amd64-fbsd ~x86-fbsd"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-gentoo-freebsd8.2"
CFLAGS="-w -O1 -pipe -ggdb"
CHOST="x86_64-gentoo-freebsd8.2"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-w -O1 -pipe -ggdb"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs chflags distlocks ebuild-locks fixlafiles news parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://ftp.fsn.hu/pub/linux/distributions/gentoo/"
LDFLAGS=""
LINGUAS="hu"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X amd64-fbsd apng bzip2 cli consolekit cracklib crypt custom-cflags custom-optimization cxx dbus dri gif gmp iconv ipv6 java5 java6 jpeg kde lzma mmx modules multilib ncurses nopie nossp nptlonly ogg opengl optimization oss pam pcre png policykit python2 qt3support qt4 session sse sse2 sse3 sse4 sse4_1 ssl ssse3 strong-optimization svg symlink tcpd tftp threads tiff unicode usb vlc vorbis wimax wps xorg zfs zlib" CAMERAS="ptp2" ELIBC="FreeBSD" INPUT_DEVICES="keyboard mouse" KERNEL="FreeBSD" LINGUAS="hu" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="BSD" VIDEO_CARDS="nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-devel/gcc-4.6.2 was built with the following:
USE="cxx (java5) (multilib) nopie nossp (-altivec) -bootstrap -build -doc (-fixed-point) -fortran (-gcj) -go -graphite -gtk -hardened (-libffi) -mudflap -multislot -nls -nocxx (-nptl) -objc -objc++ -objc-gc -openmp -test -vanilla"
CFLAGS="-w -O2 -pipe -ggdb"
CXXFLAGS="-w -O2 -pipe -ggdb"

lenovo ~ # gdb --args gcc-4.6.2 -c -o gcc-log.o gcc-log.c
GNU gdb (Gentoo 7.3.1 p1) 7.3.1
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-gentoo-freebsd8.2".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /usr/bin/gcc-4.6.2...done.
(gdb) run
Starting program: /usr/bin/gcc-4.6.2 -c -o gcc-log.o gcc-log.c
gcc-log.c: In function 'main':
gcc-log.c:7:2: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.
[Inferior 1 (process 97292) exited with code 01]
(gdb) bt
No stack.
(gdb)


This is not too informational. Where could I wrong?

Moreover strace is not an option on amd64-fbsd as at compile time it tells me:

defs.h:133:2: error: #error "FreeBSD support is only for i386 arch right now."
Comment 16 Tibor Vago 2011-11-27 19:12:36 UTC
Created attachment 293969 [details]
verbose compile log for faulty target

Come into my mind to compile the faulty C program with verbose flags. I made log but it is very interesting. The segfault code is at 0x0 address?
Comment 17 Tibor Vago 2011-11-27 20:12:00 UTC
Ok, I think the problem is with >=mpfr-3.1.0
If I recompile gcc with mpfr-3.0.1 then everything is ok.
Comment 18 SpanKY gentoo-dev 2011-11-29 01:31:42 UTC
nice ... that's a good data point

can you try installing mpfr-3.0.x and then emerging mpfr-3.1.x with FEATURES=test to see if that passes ?
Comment 19 Tibor Vago 2011-11-29 13:42:34 UTC
Created attachment 294177 [details]
mpfr-3.1.0 build log

Bingo!

======================
62 of 160 tests failed
(1 test was not run)
======================

mpfr-3.0.1_p4-r1 passes on all of the tests.
Comment 20 SpanKY gentoo-dev 2011-11-29 16:54:58 UTC
thanks, i've dropped bsd from KEYWORDS:
http://sources.gentoo.org/dev-libs/mpfr/mpfr-3.1.0.ebuild?r1=1.1&r2=1.2

next step i guess is to report to the mpfr project:
http://websympa.loria.fr/wwsympa/arc/mpfr
Comment 21 Tibor Vago 2011-11-30 20:34:46 UTC
I can't reproduce this on sparc-fbsd.
Comment 22 Naohiro Aota gentoo-dev 2011-12-20 13:00:18 UTC
I got

=======================
128 of 160 tests failed
(1 test was not run)
=======================

and there're a lot of 

/libexec/ld-elf.so.1: /usr/tmp/portage/dev-libs/mpfr-3.1.0/work/mpfr-3.1.0/tests/ttrunc: Unsupported relocation type 37 in non-PLT relocations

and segmentation faults. First, I should workaround this issue here :( missing -fPIC maybe?
Comment 23 Naohiro Aota gentoo-dev 2012-02-28 12:02:42 UTC
% gdb ./tzeta
<snip>
Reading symbols from /usr/tmp/portage/dev-libs/mpfr-3.1.0/work/mpfr-3.1.0/tests/tzeta...done.
(gdb) r
Starting program: /usr/tmp/portage/dev-libs/mpfr-3.1.0/work/mpfr-3.1.0/tests/tzeta 

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x280f1159 in mpfr_cache (dest=0xbfbfdbbc, cache=0x2808ea94, rnd=MPFR_RNDU) at cache.c:67
#2  0x280bde30 in mpfr_exp2 (y=0xbfbfddb4, x=0xbfbfdc60, rnd_mode=MPFR_RNDN) at exp2.c:124
#3  0x280cb284 in mpfr_pow (z=0xbfbfddb4, x=0xbfbfdd1c, y=0xbfbfdda4, rnd_mode=MPFR_RNDN) at pow.c:669
#4  0x280e0dbc in mpfr_ui_pow (y=0xbfbfddb4, n=8, x=0xbfbfdda4, rnd_mode=MPFR_RNDN) at ui_pow.c:36
#5  0x280ea494 in mpfr_zeta_part_a (sum=0xbfbfde80, s=0xbfbfe090, n=8) at zeta.c:123
#6  0x280eaeed in mpfr_zeta_pos (z=0xbfbfe080, s=0xbfbfe090, rnd_mode=MPFR_RNDN) at zeta.c:260
#7  0x280eb5b2 in mpfr_zeta (z=0xbfbfe080, s=0xbfbfe090, rnd_mode=MPFR_RNDN) at zeta.c:393
#8  0x08049911 in test1 () at tzeta.c:37
#9  0x0804b5a5 in main (argc=1, argv=0xbfbfe168) at tzeta.c:233
(gdb) up
#1  0x280f1159 in mpfr_cache (dest=0xbfbfdbbc, cache=0x2808ea94, rnd=MPFR_RNDU) at cache.c:67
67            cache->inexact = (*cache->func) (cache->x, MPFR_RNDN);
(gdb) list
62
63            /* Update the cache. */
64            pold = prec;
65            /* no need to keep the previous value */
66            mpfr_set_prec (cache->x, pold);
67            cache->inexact = (*cache->func) (cache->x, MPFR_RNDN);
68          }
69
70        /* now pold >= prec is the precision of cache->x */
71
(gdb) p cache
$1 = (struct __gmpfr_cache_s *) 0x2808ea94
(gdb) p cache->func
$2 = (int (*)(mpfr_ptr, mpfr_rnd_t)) 0

Looks like this issue:

http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html

I'll try the patch here
http://www.FreeBSD.org/cgi/query-pr.cgi?pr=161344&cat= and will commit
it if it works fine.
Comment 24 Naohiro Aota gentoo-dev 2012-03-08 11:21:42 UTC
The above patch solve SEGVs here. It was added to freebsd-libexec-8.2-r1. Please try it!
Comment 25 SpanKY gentoo-dev 2012-03-11 19:53:29 UTC
sounds like a bug in the freebsd core, so nothing left for toolchain.  thanks guys for your help in tracking things down!
Comment 26 Alexis Ballier gentoo-dev 2012-05-07 13:05:37 UTC
(In reply to comment #24)
> The above patch solve SEGVs here. It was added to freebsd-libexec-8.2-r1.
> Please try it!

works here -> closing, thanks