Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 953072 - (MUSL) dev-lang/rust-bin fails to compile www-client/firefox and mail-client/thunderbird due to segfault in proc-macro2 buildscript binary
Summary: (MUSL) dev-lang/rust-bin fails to compile www-client/firefox and mail-client/...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Randy Barlow
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-03 06:01 UTC by Librecat
Modified: 2025-04-06 17:01 UTC (History)
5 users (show)

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


Attachments
emerge --info output (emerge-info.txt,19.28 KB, text/plain)
2025-04-03 06:01 UTC, Librecat
Details
thunderbird esr build log(same issue on firefox:rapid) (build.log.gz,111.60 KB, application/gzip)
2025-04-03 06:06 UTC, Librecat
Details
firefox build log with rust-bin and USE=debug (build.log.gz,220.26 KB, application/gzip)
2025-04-03 07:06 UTC, Librecat
Details
Build log with dev-lang/rust-1.85.1 and www-client/firefox-137.0 (build.log.xz,85.54 KB, application/x-xz)
2025-04-06 03:03 UTC, Brahmajit Das
Details
build log without LTO & GPO (build.log.xz,113.59 KB, application/x-xz)
2025-04-06 17:01 UTC, Brahmajit Das
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Librecat 2025-04-03 06:01:57 UTC
Created attachment 923538 [details]
emerge --info output

0:  48 81 c4 70 01 00 00    add    rsp,0x170
7:  5b                      pop    rbx
8:  c3                      ret
9:  c3                      ret
a:  53                      push   rbx
b:  48 89 fa                mov    rdx,rdi
e:  31 c0                   xor    eax,eax
10: b9 4c 00 00 00          mov    ecx,0x4c
15: 48 81 ec 50 01 00 00    sub    rsp,0x150
1c: 48 8d 7c 24 20          lea    rdi,[rsp+0x20]
21: f3 ab                   rep stos DWORD PTR es:[rdi],eax
23: 48 8b 05 a3 26 01 00    mov    rax,QWORD PTR [rip+0x126a3]        # 0x126cd
2a: 48 89 10                mov    QWORD PTR [rax],rdx
2d: 31 c0                   xor    eax,eax
2f: 48 8b 0c c2             mov    rcx,QWORD PTR [rdx+rax*8]
33: 48 ff c0                inc    rax
36: 48 85 c9                test   rcx,rcx
39: 75 f4                   jne    0x2f
3b: 48 8d 04 c2             lea    rax,[rdx+rax*8]
3f: 48                      rex.W 

here is a disassembly of the bytes the kernel reported with the segfault
the failing line is 2a(i tried gdb and addr2line but the build script of proc-macro2 wasnt compiled with debug info so it didnt help) this could be a global LTO issue as most of the system was compiled with global LTO using instructions from https://wiki.gentoo.org/wiki/LTO

compiling dev-lang/rust on my musl system without global lto applied seems to  resolve the problem and the build doesnt fail very quickly from proc-macro2 crate segfaulting, since firefox and rust take a while to compile on my machine i will get back and comment on the bug report when i test building both firefox and thunderbird again using source built rust with global lto enabled
Comment 1 Librecat 2025-04-03 06:06:23 UTC
Created attachment 923539 [details]
thunderbird esr build log(same issue on firefox:rapid)
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-04-03 06:31:24 UTC
(In reply to Librecat from comment #0)
> [...]
>
> here is a disassembly of the bytes the kernel reported with the segfault
> the failing line is 2a(i tried gdb and addr2line but the build script of
> proc-macro2 wasnt compiled with debug info so it didnt help) this could be a
> global LTO issue as most of the system was compiled with global LTO using
> instructions from https://wiki.gentoo.org/wiki/LTO

As I suggested on IRC, building FF w/ debug symbols should fix that (if not, investigate why).

> 
> compiling dev-lang/rust on my musl system without global lto applied seems
> to  resolve the problem and the build doesnt fail very quickly from
> proc-macro2 crate segfaulting

I find this surprising but it's not impossible. It might explain a few things.

But wait, your title says rust-bin, not rust? so LTO should make zero difference?
Comment 3 Librecat 2025-04-03 06:55:05 UTC
i had simillar segfaults with python being compiled with lto when running its pgo testsuite and the byte highlighted in dmesg was also <48> so i initially thought these crashes were related but yes this seems more like upstream rust binaries being bad situation than a LTO issue, firefox compiled successfully with source built rust
Comment 4 Librecat 2025-04-03 06:57:15 UTC
i will quickpkg what i built and test building firefox with rust-bin with debug symbols now to see what the issue is
Comment 5 Librecat 2025-04-03 07:05:47 UTC
building with debug symbols didnt help(gdb said the memory is invalid, addr2line also didnt work) also every segfault(even the pgo testsuite of the successfully built firefox now that i looked at it) highlights <48> which makes me think this is a hardware issue so i will test on another machine that is probably known good
Comment 6 Librecat 2025-04-03 07:06:46 UTC
Created attachment 923541 [details]
firefox build log with rust-bin and USE=debug
Comment 7 Librecat 2025-04-03 14:22:20 UTC
happens with firefox-esr and rust-bin on a fresh hardened musl stage3 aswell
Comment 8 Brahmajit Das 2025-04-06 03:03:49 UTC
Created attachment 923603 [details]
Build log with dev-lang/rust-1.85.1 and www-client/firefox-137.0

I'm able to reproduce the issue on musl llvm profile with dev-lang/rust-1.85.1 and www-client/firefox-137.0, both with and without LTO enabled for firefox.


Portage 3.0.67 (python 3.12.9-final-0, default/linux/amd64/23.0/musl/llvm, gcc-14, musl-1.2.5-r3, 6.14.0-gentoo x86_64)
=================================================================
System uname: Linux-6.14.0-gentoo-x86_64-11th_Gen_Intel-R-_Core-TM-_i7-11800H_@_2.30GHz-with-libc
KiB Mem:    49028292 total,  34335032 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Sat, 05 Apr 2025 22:35:20 +0000
Head commit of repository gentoo: b2f42f2663d024856427bdaf980e2ea7f7d0660b

sh bash 5.2_p37
ld GNU ld (Gentoo 2.44 p1) 2.44.0
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo, 1.17-r2::gentoo
dev-build/cmake:           3.31.6-r1::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.7.1::gentoo
dev-lang/perl:             5.40.1::gentoo
dev-lang/python:           3.12.9::gentoo, 3.13.2::gentoo
dev-lang/rust:             1.85.1::gentoo
dev-lang/rust-bin:         1.85.1::gentoo, 1.86.0::gentoo
llvm-core/clang:           19.1.7::gentoo, 20.1.2::gentoo
llvm-core/lld:             19.1.7::gentoo, 20.1.2::gentoo
llvm-core/llvm:            19.1.7::gentoo, 20.1.2::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.61::gentoo
sys-apps/sandbox:          2.46::gentoo
sys-devel/binutils:        2.44::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/gcc:             14.2.1_p20250301::gentoo, 15.0.1_pre20250330-r2::gentoo
sys-devel/gcc-config:      2.12.1::gentoo
sys-kernel/linux-headers:  6.14::gentoo (virtual/os-headers)
sys-libs/musl:             1.2.5-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

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64_musl_llvm

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
ADDR2LINE="llvm-addr2line"
AR="llvm-ar"
AS="clang -c"
CBUILD="x86_64-pc-linux-musl"
CC="clang"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-musl"
CONFIG_PROTECT="/etc /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/sandbox.d"
CPP="clang-cpp"
CXX="clang++"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--jobs 8 --load-average 8 --with-bdeps=y --complete-graph=y --deep"
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 merge-wait network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="https://mirrors.nxtgen.com/gentoo-mirror/gentoo-source/ https://mirrors.evowise.com/gentoo/ https://mirrors.lug.mtu.edu/gentoo/"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="C.UTF8"
LD="ld.lld"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j16 -l17"
NM="llvm-nm"
OBJCOPY="llvm-objcopy"
OBJDUMP="llvm-objdump"
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"
RANLIB="llvm-ranlib"
READELF="llvm-readelf"
SHELL="/bin/bash"
STRINGS="llvm-strings"
STRIP="llvm-strip"
USE="acl amd64 bzip2 cet clang crypt iconv ipv6 libtirpc llvm-libunwind ncurses nls openmp pam pcre pic readline seccomp ssl test-rust unicode xattr zlib" ABI_X86="64" ADA_TARGET="gcc_14" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio 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="mmx mmxext sse sse2" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres17" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ARFLAGS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RUSTFLAGS, SIZE, YACC, YFLAGS
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-04-06 03:30:39 UTC
Please try to do the following (general steps here, I know that OP did some of that already):
* reproduce without LTO and PGO
* reproduce in a clean stage3 with minimal changes (and list exactly what was needed)
* reproduce when running the failing command manually
* try to build Firefox manually and reproduce it (and give instructions for that)
* try to then get cargo to give you a rustc invocation which fails
* run that rustc invocation under gdb and valgrind
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-04-06 03:32:08 UTC
(In reply to Sam James from comment #9)

* establish if rust or rust-bin is needed (which?)
Comment 11 Brahmajit Das 2025-04-06 17:01:53 UTC
Created attachment 923616 [details]
build log without LTO & GPO

(In reply to Sam James from comment #9)
> * reproduce without LTO and PGO
Same without PGO and LTO