Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 442484 - dev-libs/boost-1.49.0-r2: Segmentation fault during install phase.
Summary: dev-libs/boost-1.49.0-r2: Segmentation fault during install phase.
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: C++ Team [disbanded]
Depends on:
Reported: 2012-11-09 19:10 UTC by Walther
Modified: 2014-12-11 07:54 UTC (History)
0 users

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


Note You need to log in before you can comment on or make changes to this bug.
Description Walther 2012-11-09 19:10:38 UTC
When installing boost on my system, at the very end of the process, during the install stage, there is a segmentation fault after performing the numerous "cp":

    cp "/var/tmp/portage/dev-libs/boost-1.49.0-r2/work/boost_1_49_0/boost/math/tools/detail/polynomial_horner3_8.hpp"  "/var/tmp/portage/dev-libs/boost-1.49.0-r2/image/usr/include/boost-1_49/boost/math/tools/detail/polynomial_horner3_8.hpp"

/var/tmp/portage/dev-libs/boost-1.49.0-r2/temp/environment : ligne 5225 : 15971 Erreur de segmentation  ${BJAM} -q -d+2 gentoorelease --user-config=user-config.jam ${OPTIONS} threading=single,multi ${LINK_OPTS} runtime-link=shared --includedir="${D}usr/include" --libdir="${D}usr/$(get_libdir)" $(use python && echo --python-buildid=${PYTHON_ABI}) install

At first, I thought it was lack of space (since I keep /var/tmp in tmpfs), but even after mounting an external hard-drive on /var/tmp/ I get the same fault. Might it be related to compiling boost in a 32-bit OS that is running under a 64-bit kernel?

Reproducible: Always

Steps to Reproduce:
1. emerge boost
Actual Results:  
Segmentation fault.

Expected Results:  
No segmentation fault.

The boost install command:
* Installation of dev-libs/boost-1.49.0-r2 with CPython 2.7...
 Using the following command to install:
 * b2-1_49 -q -d+2 gentoorelease --user-config=user-config.jam  -sICU_PATH=/usr --without-mpi pch=off --boost-build=/usr/share/boost-build-1_49 --prefix="/var/tmp/portage/dev-libs/boost-1.49.0-r2/image/usr" --layout=versioned threading=single,multi link=shared runtime-link=shared --includedir="/var/tmp/portage/dev-libs/boost-1.49.0-r2/image/usr/include" --libdir="/var/tmp/portage/dev-libs/boost-1.49.0-r2/image/usr/lib" --python-buildid=2.7 install

Emerge --info:
Portage (default/linux/x86/10.0/desktop, gcc-4.5.4, glibc-2.15-r3, 3.5.7-gentoo-64 x86_64)
System uname: Linux-3.5.7-gentoo-64-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T9550_@_2.66GHz-with-gentoo-2.1
Timestamp of tree: Sat, 03 Nov 2012 08:45:01 +0000
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.10.3, 1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.4
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.4 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo Local
CFLAGS="-march=native -Os -fomit-frame-pointer -fno-var-tracking"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -Os -fomit-frame-pointer -fno-var-tracking"
FCFLAGS="-O2 -march=i686 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles news parallel-fetch parse-eapi-ebuild-head protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -march=i686 -pipe"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="fr_FR fr en_GB en es_MX es"
MAKEOPTS="-j3 -s"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
USE="3dnow X a52 aac acpi alsa avi berkdb boundschecking bzip2 cairo canna cdda cdr cjk cli cracklib crypt cscope cups curl cxx dbus dedicated dga divx divx4linux dlloader dri dts dvd dvdr dvdread emboss encode exif fam fbcon fbsplash ffmpeg fftw flac foomaticdb fortran freewnn gd gdbm gif gimp ginac gmedia gpm gstreamer gtk gtk2 gtkhtml hal hddtemp howl iconv icu idn imap imlib innodb inotify introspection ipv6 ithreads jabber java java6 jikes joystick jpeg lame lcms libnotify libsamplerate libwww lm_sensors lzma mad madwifi matroska mbox mmx mng modplug modules mp3 mp4 mpeg mplayer mudflap musepack ncurses nls nptl nsplugin ogg opencl opengl openmp pam pango pcre pdf pdflib perl png ppds pppd python quicktime readline realmedia scanner schroedinger sdl session speex spell sse sse2 ssl ssse3 svg svga tcpd tetex theora threads tiff timidity truetype udev udisks unicode upower usb v4l v4l2 vaapi vdpau vidix vim-syntax vorbis webkit win32codecs wma wmf wmp wxwidgets x264 x86 xcb xcomposite xface xft xine xml xml2 xscreensaver xv xvid zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" 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" 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 ubx" INPUT_DEVICES="evdev keyboard mouse synaptics wacom joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr_FR fr en_GB en es_MX es" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" SANE_BACKENDS="plustek pixma" USERLAND="GNU" VIDEO_CARDS="nouveau vesa" 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"
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2012-11-09 21:01:29 UTC
I'd say start by dropping -fno-var-tracking.
Comment 2 Walther 2012-11-10 01:59:10 UTC
Well, the manpage for gcc says that flag is for compilations which have debugging symbols enabled. I removed it and retried and... got the same segmentation fault.

In fact, I decided to go ahead and use CFLAGS="-march=native -Os"
I get the same segmentation fault:

/var/tmp/portage/dev-libs/boost-1.49.0-r2/temp/environment : ligne 5225 : 26556 Erreur de segmentation  ${BJAM} -q -d+2 gentoorelease --user-config=user-config.jam ${OPTIONS} threading=single,multi ${LINK_OPTS} runtime-link=shared --includedir="${D}usr/include" --libdir="${D}usr/$(get_libdir)" $(use python && echo --python-buildid=${PYTHON_ABI}) install
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2012-11-10 03:35:44 UTC
Did you rebuild boost-build with those flags? Because that's the one that segfaults.

I'd say the other thing is to find out where it segfaults:
Comment 4 Walther 2012-11-12 11:13:36 UTC
Okay, the links have helped me start debugging this.

The problem seems to be triggered by having "low" memory (I have 4GB with no swap).

The backtrace points to:

CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell ) (boost_1_49_0/tools/build/v2/engine/command.c):

if ( !no_limit )
        /* Bail if the result will not fit in MAXLINE. */
        char * s = cmd->buf;
        while ( *s )

cmd->buf was previously null, so the "while" condition crashes. Right above that, the culprit is:

        BJAM_FREE( cmd->buf );  /* free any buffer from previous iteration */

        cmd->buf = (char*)BJAM_MALLOC_ATOMIC( max_line + 1 );

        if ( cmd->buf == 0 )

Which allows cmd->buf to be null. I added a print to check what max_line was, and it starts with the value of "#define MAXLINE 102400," explaining why I am running out of memory so quickly.

Finally, I decided to change the code a bit, so that max_line starts with 1024 instead of MAXLINE:

        cmd->buf = (char*)BJAM_MALLOC_ATOMIC( max_line + 1 );

        if ( cmd->buf == 0 ) {
            /* We do not free targets/sources/shell if bailing. */
            printf("BAILED AFTER ALLOC-INT %d/%d\n", max_line+1, MAXLINE);
            cmd_free( cmd );
            return 0;

However, this now causes a crash elsewhere which I can't understand:

Core was generated by `b2-1_49 -q -d+2 gentoorelease --user-config=user-config.jam -sICU_PATH=/usr --w'.
Program terminated with signal 11, Segmentation fault.
#0  0xf7736cf1 in ?? () from /lib/
(gdb) bt
#0  0xf7736cf1 in ?? () from /lib/
#1  0x080523f5 in newstr (string=<optimized out>) at /usr/include/bits/string3.h:52
#2  0x0804c548 in var_expand (l=0x0, in=0x5c6b05 "\"", end=0x5c6b06 "", lol=0x5c6aa0, cancopyin=0) at expand.c:477
#3  0x08055ff9 in var_string (in=0x8e2fa77 " $(WINDOWS-CP-HACK) \"$(<)\"\n", out=0x5c6b06 "", outsize=1024, lol=0x5c6aa0) at variable.c:325
#4  0x08049cb4 in cmd_new (rule=0x8e39560, targets=0x122878b0, sources=0x1228bc20, shell=0x0) at command.c:63

At this point, the code is more complex than I can understand, so I cannot be certain whether the crash is still induced due to low memory or it lies somewhere else. Though I'd prefer being able to compile boost without having to add swap...

On the very least, if this is really a memory constrained situation, shouldn't the ebuild say something about it? 4GB has reasonably let me build everything out there (including libreoffice).
Comment 5 Kostas Kavourakis 2013-04-30 12:45:19 UTC
(In reply to comment #4)

I have 8GB RAM plus 1 GB swap, the install still hangs.
Comment 6 Kostas Kavourakis 2013-04-30 13:46:19 UTC
By rebuilding boost-build and boot with CFLAGS="-march=native -O2" it worked in my case. What was suggested by Diego is correct.
Comment 7 Sergey Popov gentoo-dev 2014-12-11 07:54:53 UTC
Usage of sane CFLAGS fixed the issue. Closing this as INVALID