Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 539842 - sys-apps/iproute2 fails compile on MIPS o32 ABI when executing a small binary during build
Summary: sys-apps/iproute2 fails compile on MIPS o32 ABI when executing a small binary...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: MIPS Linux
: Normal normal (vote)
Assignee: MIPS Porters
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-12 03:58 UTC by Joshua Kinard
Modified: 2015-02-21 15:51 UTC (History)
3 users (show)

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


Attachments
Reduced testcase (x.c,434 bytes, text/plain)
2015-02-16 06:12 UTC, Joshua Kinard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Kinard gentoo-dev 2015-02-12 03:58:48 UTC
This may be limited to Big-endian SGI platforms, but I am not 100% sure.  During compile of sys-apps/iproute2-3.18 and 3.17 (did not test further back), a couple of programs in the 'netam' subdir are compiled and executed, and several of them fail with SIGSEGV:

make[1]: Entering directory '/usr/obj/portage/sys-apps/iproute2-3.18.0/work/iproute2-3.18.0/netem'
mips-unknown-linux-gnu-gcc  -I../include -o maketable maketable.c -lm
mips-unknown-linux-gnu-gcc  -I../include -o normal normal.c -lm
mips-unknown-linux-gnu-gcc  -I../include -o pareto pareto.c -lm
mips-unknown-linux-gnu-gcc  -I../include -o paretonormal paretonormal.c -lm
./normal > normal.dist
/bin/sh: line 1:  2301 Segmentation fault      ./normal > normal.dist
Makefile:14: recipe for target 'normal.dist' failed
make[1]: *** [normal.dist] Error 139
make[1]: Leaving directory '/usr/obj/portage/sys-apps/iproute2-3.18.0/work/iproute2-3.18.0/netem'
Makefile:44: recipe for target 'all' failed
make: *** [all] Error 2


Dropping into the build folder, I can run a few experiments and debug what's failing, but I don't really understand why it's failing:

(cd to $PORTDIR_TMP)

# find . -executable -type f | xargs ls -l
-rwxr-xr-x 1 portage portage 16666 Feb 11 19:57 ./maketable
-rwxr-xr-x 1 root    root    46274 Feb 11 22:09 ./normal
-rwxr-xr-x 1 portage portage  7501 Feb 11 19:57 ./pareto
-rwxr-xr-x 1 portage portage 11753 Feb 11 19:57 ./paretonormal

# ./maketable
^C
(Runs fine)

# ./normal
Segmentation fault

# ./pareto
# This is the distribution table for the pareto distribution.
^C
(Runs fine)

# ./paretonormal
Segmentation fault

------------------------

Running ./normal under GDB says this:

# gdb ./normal
GNU gdb (Gentoo 7.8.1 vanilla) 7.8.1
[snip]
(gdb) run
Starting program: /usr/obj/portage/sys-apps/iproute2-3.18.0/work/iproute2-3.18.0/netem/normal

Program received signal SIGSEGV, Segmentation fault.
0x00400a74 in main (argc=1, argv=0x7fff5e94) at normal.c:33
33                      table[i] = x;

(gdb) p i
$1 = 19777

(gdb) p sizeof(table)/sizeof(*table)
$2 = 16385

So it appears to be a classic out-of-bounds error, but I don't really understand what the source code is doing to compute the iterator:

#define TABLESIZE 16384
#define TABLEFACTOR NETEM_DIST_SCALE

static double
normal(double x, double mu, double sigma)
{
        return .5 + .5*erf((x-mu)/(sqrt(2.0)*sigma));
}


int
main(int argc, char **argv)
{
        int i, n;
        double x;
        double table[TABLESIZE+1];

        for (x = -10.0; x < 10.05; x += .00005) {
                i = rint(TABLESIZE * normal(x, 0.0, 1.0));
                table[i] = x;
        }
[snip]

It suggests to me that there is something a bit off with floating point that's causing 'i' to reach such a high value, but I am not really sure.  FP math isn't really my strong point.

As seen in the make command above, these four build-time programs are compiled with rather vanilla CFLAGS, so it's nothing fancy I am doing.  I tested with other CFLAGS combinations, including various MIPS ISAs, and when specifying *any* optimization levels above -O0, I get SIGBUS instead of SIGSEGV.

Primary system that this is failing on has an R14000 CPU.  Can reproduce on a second R14000 CPU system.  However, both 'normal' and 'paretonormal' run fine on an RM7000 CPU system, even if the binary is compiled on the failing system.

This suggests a hardware conflict, but it may be kernel related, too.  Not 100% sure just yet...
Comment 1 Joshua Kinard gentoo-dev 2015-02-12 04:03:23 UTC
Failing system #1 (SGI Octane):

Portage 2.2.15 (python 3.3.5-final-0, default/linux/mips/13.0/o32, gcc-4.7.4, glibc-2.20-r1, 3.19.0-rc7-mipsgit-20150207 mips64)
=================================================================
System uname: Linux-3.19.0-rc7-mipsgit-20150207-mips64-R14000_V2.4_FPU_V0.0-with-gentoo-2.2
KiB Mem:     2043304 total,   1770672 free
KiB Swap:    3145716 total,   3145716 free
Timestamp of tree: Thu, 05 Feb 2015 07:15:01 +0000
sh bash 4.3_p33
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.3_p33
dev-lang/perl:            5.20.1-r4
dev-lang/python:          2.7.9-r1, 3.3.5-r1, 3.4.2
dev-util/pkgconfig:       0.28-r2
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.13.9
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.4_p6-r2, 1.5-r2, 1.6.3-r2, 1.7.9-r3, 1.8.5-r5, 1.9.6-r4, 1.10.3-r1, 1.11.6, 1.15
sys-devel/binutils:       2.24-r3
sys-devel/gcc:            4.6.4, 4.7.4
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.5
sys-devel/make:           4.1-r1
sys-kernel/linux-headers: 3.18 (virtual/os-headers)
sys-libs/glibc:           2.20-r1
Repositories: gentoo local
ACCEPT_KEYWORDS="mips ~mips"
ACCEPT_LICENSE="* -@EULA"
CBUILD="mips-unknown-linux-gnu"
CFLAGS="-O2 -march=r10000 -mtune=r10000 -pipe -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fno-stack-protector"
CHOST="mips-unknown-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/init.d /etc/pam.d /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -march=r10000 -mtune=r10000 -pipe -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fno-stack-protector"
DISTDIR="/usr/portage/distfiles"
FCFLAGS=""
FEATURES="assume-digests binpkg-logs candy cgroup config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd /etc/systemd"
LDFLAGS="-Wl,-z,now -Wl,-z,relro"
MAKEOPTS="-j1"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/obj"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local"
USE="acl berkdb bzip2 cli cracklib crypt cxx gdbm ip30 ipv6 libav mips modules ncurses nls nossp nptl nptlonly pam pcre perl pppd python readline ssl tcpd unicode userlocales zlib" ABI_MIPS="o32" ALSA_CARDS="au1x00" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="dummy fbdev impact newport" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON


------------------------------------------------


Failing system #2 (SGI Onyx2):

Portage 2.2.15 (python 3.3.5-final-0, default/linux/mips/13.0/o32, gcc-4.7.4, glibc-2.20-r1, 3.19.0-rc7-mipsgit-20150207 mips64)
=================================================================
System uname: Linux-3.19.0-rc7-mipsgit-20150207-mips64-R14000_V1.4_FPU_V0.0-with-gentoo-2.2
KiB Mem:     8235356 total,   4748956 free
KiB Swap:    1349448 total,   1349448 free
Timestamp of tree: Thu, 05 Feb 2015 07:15:01 +0000
sh bash 4.3_p33-r1
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.3_p33-r1
dev-lang/perl:            5.20.1-r4
dev-lang/python:          2.7.9-r1, 3.3.5-r1, 3.4.2
dev-util/pkgconfig:       0.28-r2
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.13.9
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.4_p6-r2, 1.5-r2, 1.6.3-r2, 1.7.9-r3, 1.8.5-r5, 1.9.6-r4, 1.10.3-r1, 1.11.6, 1.15
sys-devel/binutils:       2.24-r3
sys-devel/gcc:            4.7.4
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.5
sys-devel/make:           4.1-r1
sys-kernel/linux-headers: 3.18 (virtual/os-headers)
sys-libs/glibc:           2.20-r1
Repositories: gentoo local
ACCEPT_KEYWORDS="mips ~mips"
ACCEPT_LICENSE="* -@EULA"
CBUILD="mips-unknown-linux-gnu"
CFLAGS="-O2 -march=r10000 -mtune=r10000 -mno-fix-r10000 -mplt -pipe -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fno-stack-protector"
CHOST="mips-unknown-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/init.d /etc/pam.d /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -march=r10000 -mtune=r10000 -mno-fix-r10000 -mplt -pipe -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fno-stack-protector"
DISTDIR="/usr/portage/distfiles"
FCFLAGS=""
FEATURES="assume-digests binpkg-logs candy cgroup config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd /etc/systemd"
LDFLAGS="-Wl,-z,now -Wl,-z,relro"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/ramfs"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local"
USE="acl berkdb bzip2 cli cracklib crypt cxx gdbm ip30 ipv6 libav mips modules ncurses nls nossp nptl nptlonly pam pcre perl pppd python readline ssl tcpd unicode userlocales zlib" ABI_MIPS="o32" ALSA_CARDS="au1x00" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="dummy fbdev impact newport" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON


------------------------------------------------


Working system #1 (SGI O2):

Portage 2.2.15 (python 2.7.9-final-0, default/linux/mips/13.0/o32, gcc-4.7.4, glibc-2.20-r1, 3.19.0-rc7-mipsgit-20150207 mips64)
=================================================================
System uname: Linux-3.19.0-rc7-mipsgit-20150207-mips64-RM7000_V3.3_FPU_V2.0-with-gentoo-2.2
KiB Mem:      509712 total,    348224 free
KiB Swap:    2097120 total,   2097120 free
Timestamp of tree: Sun, 01 Feb 2015 02:15:01 +0000
sh bash 4.3_p33-r1
ld GNU ld (Gentoo 2.24 p1.4) 2.24
distcc 3.2rc1 mips-unknown-linux-gnu [disabled]
app-shells/bash:          4.3_p33-r1
dev-lang/perl:            5.20.1-r4
dev-lang/python:          2.7.9-r1, 3.3.5-r1, 3.4.2
dev-util/pkgconfig:       0.28-r2
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.13.8
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.6-r1, 1.13.4, 1.14.1, 1.15
sys-devel/binutils:       2.24-r3
sys-devel/gcc:            4.7.4
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.5
sys-devel/make:           4.1-r1
sys-kernel/linux-headers: 3.18 (virtual/os-headers)
sys-libs/glibc:           2.20-r1
Repositories: gentoo local
Installed sets: @system
ACCEPT_KEYWORDS="mips ~mips"
ACCEPT_LICENSE="* -@EULA"
CBUILD="mips-unknown-linux-gnu"
CFLAGS="-O2 -march=rm7000 -mtune=rm7000 -pipe -mplt -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fmodulo-sched -ftree-vectorize"
CHOST="mips-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/init.d /etc/pam.d /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=rm7000 -mtune=rm7000 -pipe -mplt -fomit-frame-pointer -ftracer -fforce-addr -fivopts -fmodulo-sched -ftree-vectorize"
DISTDIR="/usr/portage/distfiles"
FCFLAGS=""
FEATURES="assume-digests binpkg-logs candy cgroup config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd /etc/systemd"
LDFLAGS="-Wl,-z,now -Wl,-z,relro"
MAKEOPTS="-j1"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/obj"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local"
USE="acl berkdb bzip2 cli cracklib crypt cxx gdbm ip30 ipv6 mips modules ncurses nls nossp nptl nptlonly pam pcre perl pppd python readline ssl tcpd unicode userlocales zlib" ABI_MIPS="o32" ALSA_CARDS="au1x00" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="dummy fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 2 Joshua Kinard gentoo-dev 2015-02-12 06:02:25 UTC
...And the game is afoot!  This flaw only appears to affect o32 ABI.  n32 ABI compiles iproute2-3.18.0 fine.

It also looks like I somehow compiled this package a few days ago under an o32 ABI during a catalyst run.  Only thing I changed since then was the kernel, so...
Comment 3 Joshua Kinard gentoo-dev 2015-02-12 06:22:36 UTC
Markos, Could this be related to the recent linux-mips upstream discussions regarding the new O32 FP ABI support?
Comment 4 Anthony Basile gentoo-dev 2015-02-12 20:16:10 UTC
(In reply to Joshua Kinard from comment #3)
> Markos, Could this be related to the recent linux-mips upstream discussions
> regarding the new O32 FP ABI support?

Can you get me the link to that change?  I'm not familiar with what you are referring to.  BTW, I tested and it works for me on the lemore.  kernel = 3.12.22, ie old.
Comment 5 Joshua Kinard gentoo-dev 2015-02-13 01:09:50 UTC
(In reply to Anthony Basile from comment #4)
> (In reply to Joshua Kinard from comment #3)
> > Markos, Could this be related to the recent linux-mips upstream discussions
> > regarding the new O32 FP ABI support?
> 
> Can you get me the link to that change?  I'm not familiar with what you are
> referring to.  BTW, I tested and it works for me on the lemore.  kernel =
> 3.12.22, ie old.

That's the thing, is I am not sure if this is related to any of those changes (nor do I know which specific one it is).  The factors are o32 ABI, floating point code (which the cited code clearly is), and a recent kernel, so they do seem to be related.

Unfortunately, I went and cleaned out my /tftpboot folder and discarded older kernels, and kept only 3.19-rc7 and 3.18.6 builds.  I get the same error under 3.18.6 as well.  Might have to fall back to 3.18.5 and one of my older linux-mips git cuts to see if I can isolate the actual problem.  I can't remember which kernel I used to build one of the stage3's that built iproute2 properly.

Some links I can find via e-mail are:

[PATCH] MIPS: bypass FP mode checks when CONFIG_MIPS_O32_FP64_SUPPORT==n
http://www.linux-mips.org/archives/linux-mips/2015-01/msg00337.html

[PATCH] MIPS: ELF: fix loading o32 binaries on 64-bit kernels
http://www.linux-mips.org/archives/linux-mips/2015-01/msg00155.html

There's probably a few more, but I don't recall their subject lines.  Markos might know more, since I think he's worked on the 64bit FP stuff in o32 binaries some.
Comment 6 Anthony Basile gentoo-dev 2015-02-13 12:09:18 UTC
(In reply to Joshua Kinard from comment #5)
> Some links I can find via e-mail are:
> 
> [PATCH] MIPS: bypass FP mode checks when CONFIG_MIPS_O32_FP64_SUPPORT==n
> http://www.linux-mips.org/archives/linux-mips/2015-01/msg00337.html

I'm not sure what this does.

> 
> [PATCH] MIPS: ELF: fix loading o32 binaries on 64-bit kernels
> http://www.linux-mips.org/archives/linux-mips/2015-01/msg00155.html

This is correct.

> 

All my mips machines are tied up at the moment building stuff.  I'll test a more recent kernel to see if I hit the issue.  I didn't look at normal.c, so do you have any redcued code? (If I hit the bug I can do that, but I can't right now.)
Comment 7 Joshua Kinard gentoo-dev 2015-02-14 01:14:52 UTC
(In reply to Anthony Basile from comment #6)
> 
> All my mips machines are tied up at the moment building stuff.  I'll test a
> more recent kernel to see if I hit the issue.  I didn't look at normal.c, so
> do you have any redcued code? (If I hit the bug I can do that, but I can't
> right now.)

Mine are as well (kinda).  I reboot the Onyx2 every stage build because of a kernel BUG() in mm/vmsvan.c that I trip up if I run it for too long.  I posted the relevant portion of normal.c in my opening comment, as well as line #33 where GDB says the SIGSEGV happens at.
Comment 8 SpanKY gentoo-dev 2015-02-15 08:33:37 UTC
sounds like everything is pointing to a bug on the mips side ?  i guess bounce back to base-system if you think it's actually a problem in iproute2.
Comment 9 Joshua Kinard gentoo-dev 2015-02-16 06:12:23 UTC
Created attachment 396574 [details]
Reduced testcase

This is a reduced testcase of the problem.  SIGSEGV on o32, runs fine on n32.  Tested amd64, too, and it runs fine there as well.  I can workaround the problem on o32 by doubling the size of the 'table' array, OR by switching to an older gcc.

If I add a stdio.h include and insert this printf:
printf("i: %d\n", i);

Inside the 'for' loop, after assigning 'i', then I can determine that it SIGSEGV's when printing line #199591.  If I double the size of the array, it outputs exactly 401,001 lines, same on amd64.

I tried changing the array size, and at 4096+1 entries, the testcase will sometimes run fine and sometimes SIGSEGV.  Higher than 4096 increases the likelihood of a SIGSEGV.

All of this is with gcc-4.7.4.  If I switch to gcc-4.6.4, it compiles and runs fine on o32, so it looks like I may have a gcc-4.7 PR now.  which sucks, because I cannot use >gcc-4.8.0 on R10000 systems due to PR61538, which has received no attention from upstream so far.
Comment 10 Joshua Kinard gentoo-dev 2015-02-16 06:14:24 UTC
CC'ing toolchain for comments on the testcase and gcc-4.7.4/4.6.4 bit.  Does this look like a regression here?  I don't know if gcc upstream will be open to trying to track this down and fixing it in another 4.7.x push.  I can't use 4.8 until PR61538 is addressed on these systems, either.
Comment 11 Joshua Kinard gentoo-dev 2015-02-18 12:47:32 UTC
gcc-4.9.2 compiles this fine, so once Bug #516548 is fixed, then this one can be marked fixed as well.  Not going to pursue notifying upstream, since I think they're done with gcc-4.7.x.
Comment 12 Anthony Basile gentoo-dev 2015-02-20 12:39:24 UTC
(In reply to Joshua Kinard from comment #11)
> gcc-4.9.2 compiles this fine, so once Bug #516548 is fixed, then this one
> can be marked fixed as well.  Not going to pursue notifying upstream, since
> I think they're done with gcc-4.7.x.

I wasn't able to reproduce this with your reduced code (or at all) so some other factor is coming to play.  The only thing I'd recommend is trying to reduce your code even more.  I would suspect the erf() or sqrt() function since they would make most use of the floating point artithmetic.  Also a lot of that is done in the glibc so could it be a bad implementation there? I don't know, I'm just trying to figure out what that second factor is.
Comment 13 Joshua Kinard gentoo-dev 2015-02-20 13:22:52 UTC
(In reply to Anthony Basile from comment #12)
> (In reply to Joshua Kinard from comment #11)
> > gcc-4.9.2 compiles this fine, so once Bug #516548 is fixed, then this one
> > can be marked fixed as well.  Not going to pursue notifying upstream, since
> > I think they're done with gcc-4.7.x.
> 
> I wasn't able to reproduce this with your reduced code (or at all) so some
> other factor is coming to play.  The only thing I'd recommend is trying to
> reduce your code even more.  I would suspect the erf() or sqrt() function
> since they would make most use of the floating point artithmetic.  Also a
> lot of that is done in the glibc so could it be a bad implementation there?
> I don't know, I'm just trying to figure out what that second factor is.

You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?
Comment 14 Anthony Basile gentoo-dev 2015-02-20 18:10:41 UTC
(In reply to Joshua Kinard from comment #13)

> 
> You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?

Yes.  kernel = vanilla 3.12.22
Comment 15 Joshua Kinard gentoo-dev 2015-02-20 19:35:44 UTC
(In reply to Anthony Basile from comment #14)
> (In reply to Joshua Kinard from comment #13)
> 
> > 
> > You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?
> 
> Yes.  kernel = vanilla 3.12.22

Able to try a newer kernel, 3.18 or 3.19?  If it's tied to the o32 FP 64bit stuff, you'll need something that new to trigger it.  Also, big-endian?  I can't test little-endian anymore.  But the fact that 4.6.4 and 4.9.2 work fine indicates it's something 4.7.x is doing and was fixed, but never backported.
Comment 16 Anthony Basile gentoo-dev 2015-02-21 01:07:38 UTC
(In reply to Joshua Kinard from comment #15)
> (In reply to Anthony Basile from comment #14)
> > (In reply to Joshua Kinard from comment #13)
> > 
> > > 
> > > You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?
> > 
> > Yes.  kernel = vanilla 3.12.22
> 
> Able to try a newer kernel, 3.18 or 3.19? 

I can try, but it will be a while before I get there.  I'm busy building a mips I uclibc stage for a friend :P


> If it's tied to the o32 FP 64bit
> stuff, you'll need something that new to trigger it.  Also, big-endian? 

All my big endian systems are stuck on 2.6.28.9.

> I
> can't test little-endian anymore.  But the fact that 4.6.4 and 4.9.2 work
> fine indicates it's something 4.7.x is doing and was fixed, but never
> backported.

Probably, I don't know how much effort we should put into nailing this one.
Comment 17 Joshua Kinard gentoo-dev 2015-02-21 13:48:09 UTC
(In reply to Anthony Basile from comment #16)
> (In reply to Joshua Kinard from comment #15)
> > (In reply to Anthony Basile from comment #14)
> > > (In reply to Joshua Kinard from comment #13)
> > > 
> > > > 
> > > > You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?
> > > 
> > > Yes.  kernel = vanilla 3.12.22
> > 
> > Able to try a newer kernel, 3.18 or 3.19? 
> 
> I can try, but it will be a while before I get there.  I'm busy building a
> mips I uclibc stage for a friend :P

Gee, I wonder who that could be? ;)


> > If it's tied to the o32 FP 64bit
> > stuff, you'll need something that new to trigger it.  Also, big-endian? 
> 
> All my big endian systems are stuck on 2.6.28.9.

Wow, that's old.  What's holding the kernel back?


> > I
> > can't test little-endian anymore.  But the fact that 4.6.4 and 4.9.2 work
> > fine indicates it's something 4.7.x is doing and was fixed, but never
> > backported.
> 
> Probably, I don't know how much effort we should put into nailing this one.

Agreed.  If you want, mark this as WONTFIX.  I'm already building all of my stages over again on gcc-4.9.2.
Comment 18 Anthony Basile gentoo-dev 2015-02-21 15:51:24 UTC
(In reply to Joshua Kinard from comment #17)
> (In reply to Anthony Basile from comment #16)
> > (In reply to Joshua Kinard from comment #15)
> > > (In reply to Anthony Basile from comment #14)
> > > > (In reply to Joshua Kinard from comment #13)
> > > > 
> > > > > 
> > > > > You were using gcc-4.7.4 on an o32 ABI?  64bit kernel by chance?
> > > > 
> > > > Yes.  kernel = vanilla 3.12.22
> > > 
> > > Able to try a newer kernel, 3.18 or 3.19? 
> > 
> > I can try, but it will be a while before I get there.  I'm busy building a
> > mips I uclibc stage for a friend :P
> 
> Gee, I wonder who that could be? ;)
> 
> 
> > > If it's tied to the o32 FP 64bit
> > > stuff, you'll need something that new to trigger it.  Also, big-endian? 
> > 
> > All my big endian systems are stuck on 2.6.28.9.
> 
> Wow, that's old.  What's holding the kernel back?
> 
> 

Old ubiquity routerstation.  Not very friendly to upgrading.

> > > I
> > > can't test little-endian anymore.  But the fact that 4.6.4 and 4.9.2 work
> > > fine indicates it's something 4.7.x is doing and was fixed, but never
> > > backported.
> > 
> > Probably, I don't know how much effort we should put into nailing this one.
> 
> Agreed.  If you want, mark this as WONTFIX.  I'm already building all of my
> stages over again on gcc-4.9.2.