When building nodejs with gcc-13, while the build completes successfully, the generated binary segfaults on launch. Upstream issue reported here https://github.com/nodejs/node/issues/47865 Reproducible: Always Steps to Reproduce: 1. Emerge sys-devel/gcc-13.1.0(-r1) 2. Emerge net-libs/nodejs 3. Launch nodejs in a terminal ($ node) Actual Results: The node binary crashes in a while with SIGSEGV Signal: 11 (SEGV) Timestamp: Mon 2023-05-15 13:39:10 IST (20h ago) Command Line: node Executable: /usr/bin/node Control Group: /user.slice/user-1000.slice/session-c4.scope Unit: session-c4.scope Slice: user-1000.slice Session: c4 Expected Results: Binary should not crash. Per upstream issue, `-fno-ipa-icf` is required when building nodejs with gcc-13 emerge --info --------------- Portage 3.0.47 (python 3.11.3-final-0, default/linux/amd64/17.1/no-multilib/systemd/merged-usr, gcc-13, glibc-2.37-r3, 6.2.12-gentoo x86_64) ================================================================= System uname: Linux-6.2.12-gentoo-x86_64-AMD_Ryzen_5_PRO_2500U_w-_Radeon_Vega_Mobile_Gfx-with-glibc2.37 KiB Mem: 31759528 total, 17823472 free KiB Swap: 0 total, 0 free Timestamp of repository gentoo: Tue, 16 May 2023 04:02:02 +0000 Head commit of repository gentoo: fb928adcb3adeee6d569452cab7ddd400edffbd1 Head commit of repository ambasta: 1cc4cad6afd13937e6145376eb28fe2cb545a53f sh bash 5.2_p15-r2 ld GNU ld (Gentoo 2.40 p5) 2.40.0 app-misc/pax-utils: 1.3.7::gentoo app-shells/bash: 5.2_p15-r2::gentoo dev-java/java-config: 2.3.1::ambasta dev-lang/perl: 5.36.1-r1::gentoo dev-lang/python: 3.11.3::gentoo dev-lang/rust: 1.69.0-r1::ambasta dev-util/cmake: 3.26.3::gentoo dev-util/meson: 1.1.0::gentoo sys-apps/baselayout: 2.13-r1::gentoo sys-apps/sandbox: 2.30-r1::gentoo sys-apps/systemd: 253.4::gentoo sys-devel/autoconf: 2.13-r8::gentoo, 2.71-r6::gentoo sys-devel/automake: 1.16.5-r1::gentoo sys-devel/binutils: 2.40-r5::gentoo sys-devel/binutils-config: 5.5::gentoo sys-devel/clang: 16.0.3::gentoo sys-devel/gcc: 13.1.0-r1::gentoo sys-devel/gcc-config: 2.11::gentoo sys-devel/libtool: 2.4.7-r1::gentoo sys-devel/llvm: 16.0.3::gentoo sys-devel/make: 4.4.1::gentoo sys-kernel/linux-headers: 6.3::gentoo (virtual/os-headers) sys-libs/glibc: 2.37-r3::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: git sync-uri: https://github.com/gentoo-mirror/gentoo.git priority: -1000 volatile: False ambasta location: /var/db/repos/ambasta sync-type: git sync-uri: https://github.com/ambasta/ambasta.git masters: gentoo volatile: False Installed sets: @devutils, @editors, @fonts, @k8s, @nodevelop, @sway ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="@FREE linux-fw-redistributable MSttfEULA no-source-code" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.9/conf" 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" CXXFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" DISTDIR="/var/cache/distfiles" EMERGE_DEFAULT_OPTS="--autounmask=n --with-bdeps=y --complete-graph" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news nodoc noinfo parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync warn-on-large-env xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" INSTALL_MASK=" /usr/share/locale -/usr/share/locale/en -/usr/share/locale/en_US" LANG="en_US.UTF-8" LDFLAGS="-fuse-ld=mold -Wl,-O1 -Wl,--as-needed" LEX="flex" LINGUAS="en_US" MAKEOPTS="-j8" PKGDIR="/var/cache/binpkgs" 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" RUSTFLAGS="-C target-cpu=native -C link-arg=-fuse-ld=mold" SHELL="/bin/bash" USE="acl amd64 bpf bzip2 cleartype_hinting cli crypt dbus dns-over-tls dri gdbm gles2 gnome-keyring headless-awt iconv icu kms libglvnd libtirpc lto lz4 lzma ncurses networkmanager nptl pam pcre pgo pipewire policykit readline seccomp ssl systemd test-rust udev unicode user-session vaapi vulkan wayland xattr z3 zink zlib" ABI_X86="64" ADA_TARGET="gnat_2021" ALSA_CARDS="hda-intel" 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 pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="X86 AMDGPU" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby30" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS -------------------- emerge -pv nodejs -------------------- [ebuild R ] net-libs/nodejs-20.1.0-r1:0/20::ambasta USE="corepack icu inspector lto ssl system-icu system-ssl -debug -doc -npm -pax-kernel -snapshot -test" CPU_FLAGS_X86="sse2" 0 KiB
Created attachment 861781 [details, diff] Patch to resolve the issue The patch applies the fix recommended at the upstream issue, and generates a stable binary.
Thanks.
What CFLAGS + CXXFLAGS + LDFLAGS did you use to compile nodejs? The upstream report says -O2 is enough for them for the miscompilation to occur. Was it for you?
Per emerge --info, the C(XX)FLAGS are CFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" CXXFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" The flags have not been overwritten in env or otherwise. Have triggered a O2 rebuild to see if the issue persists
O2 rebuild seems fine. I think the issue only occurs with O3
Issue has been resolved in subsequent releases of NodeJS in upstream.
Sorry, I thought this was resolved (and missed that my patches for fno-ipa-icf) were actually being applied!
Build net-libs/nodejs-20.11.1 with sys-devel/mold-2.30.0 and sys-devel/gcc-13.2.1_p20240210 CXXFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" CFLAGS="-march=native -pipe -fno-stack-protector -O3 -fuse-ld=mold" LDFLAGS="-fuse-ld=mold -Wl,-O1 -Wl,--as-needed" I can not reproduce the problem. It appears to be fixed upstream quietly.
Closing since this is fixed upstream.