I'm trying to emerge elixir; I get this error: Compiled lib/elixir/lib/file.ex error: badarg stacktrace: [{re,replace, [[],<<"^[ \r\n\t]+|[ \r\n\t]+$">>,<<>>, [global,{return,binary}]], [{file,"re.erl"},{line,362}]}, {'Elixir.System',get_revision,0,[{file,"expanding macro"}]}, {'Elixir.System',revision,0, [{file,"/var/tmp/portage/dev-lang/elixir-1.8.1/work/elixir-1.8.1/lib/elixir/lib/system.ex"}, {line,129}]}, {elixir,eval_forms,4,[{file,"src/elixir.erl"},{line,258}]}, {elixir_compiler,eval_forms,3, [{file,"src/elixir_compiler.erl"},{line,49}]}, {elixir_compiler,quoted,2, [{file,"src/elixir_compiler.erl"},{line,23}]}, {elixir_compiler,bootstrap_file,1, [{file,"src/elixir_compiler.erl"},{line,130}]}, {elixir_compiler,'-bootstrap/0-lc$^1/1-0-',1, [{file,"src/elixir_compiler.erl"},{line,126}]}] make: *** [Makefile:74: lib/elixir/ebin/Elixir.Kernel.beam] Error 1 Reproducible: Always Portage 2.3.62 (python 3.5.7-final-0, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-8.3.0, glibc-2.28-r5, 5.0.4-cova x86_64) ================================================================= System uname: Linux-5.0.4-cova-x86_64-Intel-R-_Core-TM-_i7-6820HQ_CPU_@_2.70GHz-with-gentoo-2.6 KiB Mem: 65295816 total, 57216824 free KiB Swap: 8388604 total, 8388604 free Timestamp of repository gentoo: Tue, 26 Mar 2019 06:24:20 +0000 Head commit of repository gentoo: 03018f9e94d2648b43420c891014cf389151b0d6 sh bash 5.0_p3-r1 ld GNU gold (Gentoo 2.32 p1 2.32.0) 1.16 app-shells/bash: 5.0_p3-r1::gentoo dev-java/java-config: 2.2.0-r4::gentoo dev-lang/perl: 5.28.0::gentoo dev-lang/python: 2.7.16::gentoo, 3.5.7::gentoo, 3.6.8::gentoo, 3.7.2::gentoo dev-util/cmake: 3.14.0::gentoo dev-util/pkgconfig: 0.29.2::gentoo sys-apps/baselayout: 2.6-r1::gentoo sys-apps/sandbox: 2.17::gentoo sys-devel/autoconf: 2.13-r1::gentoo, 2.69-r4::gentoo sys-devel/automake: 1.11.6-r3::gentoo, 1.13.4-r2::gentoo, 1.16.1-r1::gentoo sys-devel/binutils: 2.32::gentoo sys-devel/gcc: 8.3.0::gentoo sys-devel/gcc-config: 2.0::gentoo sys-devel/libtool: 2.4.6-r5::gentoo sys-devel/make: 4.2.1-r4::gentoo sys-kernel/linux-headers: 5.0-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.28-r5::gentoo Repositories: gentoo location: /usr/portage sync-type: git sync-uri: https://anongit.gentoo.org/git/repo/sync/gentoo.git priority: -1000 sync-git-verify-commit-signature: yes kde location: /var/lib/layman/kde sync-type: laymansync sync-uri: https://github.com/gentoo/kde.git masters: gentoo priority: 50 local location: /usr/overlay masters: gentoo priority: 51 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O3 -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -flto=4 -fuse-linker-plugin -pipe -fpie -fpic -fstack-protector-strong -fstack-clash-protection" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /usr/share/sddm/scripts/Xsetup" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-march=native -O3 -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -flto=4 -fuse-linker-plugin -pipe -fpie -fpic -fstack-protector-strong -fstack-clash-protection" DISTDIR="/usr/portage/distfiles" ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="https://mirror.netcologne.de/gentoo/ http://gentoo.mirrors.ovh.net/gentoo-distfiles/ https://mirrors.evowise.com/gentoo/" LANG="en_IE.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -march=native -O3 -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -flto=4 -fuse-linker-plugin -pipe -fpie -fpic -fstack-protector-strong -fstack-clash-protection -Wl,--as-needed -Wl,--hash-style=gnu" LINGUAS="en it de" MAKEOPTS="-j4" 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 --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="3dnow 3dnowext 3dnowprefetch X \ a52 aac aalib acl acpi activities aim alsa amd64 apng appstream ares asf ati audio audiofile avahi bash-completion berkdb bidi bl bluetooth branding bri bzip2 cairo caps cdda cdr cjk cli crypt cups curl cxx dba dbus declarative device-mapper dga divx divx4linux dri dts dv dvb dvd dvdr dvdread eap-sim edl egl emboss encode ethereal evdev exif expat faad fam fame fbcon ffmpeg fftw flac force-cgi-redirect fortran ftp gallium garmin gd gdbm gif gimp glamor gmedia gmp gnutls gphoto2 gpm gps gsm gtk h264 h323 iconv icq icu idn ifp ilbc imagemagick imap innodb ipod iproute2 ipv6 ithreads jabber java javascript joystick jpeg kde kipi kontact kvm kwallet lastfm lcms ldap libnotify libtirpc libvirtd live lm_sensors lua lvm lxc lzma lzo mad maildir matroska mbox mdnsresponder-compat mhash mime mjpeg mmap mmx mmxext mng mozdevelop mozilla mp3 mp4 mpeg msn mtp multilib mysql ncurses network networkmanager new-hpcups nfsv4 njb nls nptl nptlonly offensive ofx ogg oggvorbis ogm openal openexr opengl openmp oscar pam pango parted pcap pcre pdf phonon php plasma plotutils png policykit ppds pulseaudio qemu qml qt5 readline real rtc ruby samba sasl sdl seccomp semantic-desktop semantic-destkop sha512 sip slang slp smartcard sndfile snmp sox speex spell srt sse sse2 ssh ssl ssse3 startup-notification svg symlink systemd tcltk tcpd telepathy theora threads tiff tk touchpad tremor truetype udev udisks unicode upower usb utempter v4l v4l2 vaapi vcd vde vdpaum vhosts video videos vim-syntax virt-network virtualbox vorbis vulkan wav wayland webkit widgets wifi wmf wmp wps wxwidgets wxwindows x264 xanim xattr xcb xcomposite xface xft xine xinerama xml xosd xpm xscreensaver xsl xv xvid zeroconf zlib zpm" ABI_X86="64 32" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en it de en_IE" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="X86" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_5 python3_6" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby24 ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="i965 intel nvidia v4l" 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: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 570832 [details] build.log
> CFLAGS="-march=native -O3 -fgraphite-identity -floop-nest-optimize -ftree-loop-distribution -flto=4 -fuse-linker-plugin -pipe -fpie -fpic -fstack-protector-strong -fstack-clash-protection" I can't reproduce with CFLAGS=-O2. My guess is that erlags was miscompiled with those flags. 1. Can you check if CFLAGS=-O2 works? 2. And if it does can you find minimal set of flags needed to break it? 3. Also please expand -march=native into set of flags for your CPU: https://wiki.gentoo.org/wiki/Gcc-ICE-reporting-guide#Expand_-march.3Dnative.2C_exact_gcc_version_and_other_system-specific_options
Reproduced locally as well. It'e enough to build erlang with CFLAGS/LDFLAGS=-flto. Working system (CFLAGS='-O2'): $ erl -noshell -eval 're:replace("abcd","c","[&]",[{return,list}]).' -s erlang halt <quiet> Broken system (CFLAGS='-O2 -flto'): $ erl -noshell -eval 're:replace("abcd","c","[&]",[{return,list}]).' -s erlang halt {"init terminating in do_boot",{badarg,[{re,replace,["abcd","c","[&]",[{return,list}]],[{file,"re.erl"},{line,362}]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}} init terminating in do_boot ({badarg,[{re,replace,[[_],[_],[_],[_]],[{_},{_}]},{erl_eval,do_apply,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}) Crash dump is being written to: erl_crash.dump...done Probably re:replace/4 is miscompiled.
The bug happens in bundled libpcre2 in erlang. optimizes stack overflow check into always-overflow. Somewhere around here: https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_bif_re.c#L79 The following also triggers the similar failure on LTO system: # USE=test FEATURES='test' emerge -v1 dev-libs/libpcre2
Confirmed, thanks! Removing lto flag from erlang allows the compilation of elixir to go thru. Thanks again.
Proposed patch to erlang upstream: https://github.com/erlang/otp/pull/2194
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ac0ba596486e18bea03c0a59cc95b0c036443ebb commit ac0ba596486e18bea03c0a59cc95b0c036443ebb Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-05-26 08:20:45 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-05-26 08:25:54 +0000 dev-lang/erlang: fix lto support, bug #681778 re:replace/4 used libpcre2 with a stack overflow check. lto was smart enough to inline the check too much to make it useless. The changes uninlines stack prober and fixes re:replace/4. Reported-by: Fabio Coatti Closes: https://bugs.gentoo.org/681778 Package-Manager: Portage-2.3.66, Repoman-2.3.12 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-lang/erlang/erlang-21.3-r1.ebuild | 161 ++++++++++++++++++++++++++++ dev-lang/erlang/files/erlang-21.3-lto.patch | 140 ++++++++++++++++++++++++ 2 files changed, 301 insertions(+)