Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 927839 - dev-libs/nss-3.91: build failed with segmentation fault
Summary: dev-libs/nss-3.91: build failed with segmentation fault
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Mozilla Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 915000
  Show dependency tree
 
Reported: 2024-03-26 07:03 UTC by Xi
Modified: 2024-07-19 16:06 UTC (History)
7 users (show)

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


Attachments
build.log (build.log,658.68 KB, text/x-log)
2024-03-26 07:03 UTC, Xi
Details
nss 3.99 build log (nss-3.99-build.log,850.13 KB, application/octet-stream)
2024-04-06 08:53 UTC, Xi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xi 2024-03-26 07:03:07 UTC
Found this error in the build log.

moduleSpec configdir='' certPrefix='' keyPrefix='' secmod='' flags=noCertDB, noModDB
Generate an HMAC key ... 
/var/tmp/portage/dev-libs/nss-3.91/work/nss-3.91/nss-abi_x86_64.amd64/cmd/shlibsign/./sign.sh: line 13:  5558 Segmentation fault      (core dumped) "${2}"/shlibsign -v -i "${5}"
make[5]: *** [Makefile:92: ../../dist/Linux6.7_x86_64_gcc_glibc_PTH_64_OPT.OBJ/lib/libsoftokn3.chk] Error 139


Reproducible: Always

Steps to Reproduce:
1. emerge '=dev-libs/nss-3.91'
2.
3.
Actual Results:  
build failed with segmentation error

Expected Results:  
nss is installed

I have both gcc-13 and clang-17 on my system, and I tried both compilers, and both gave me similar errors.

I also tried nss-3.90.2 and nss-3.99 and got the same error. I guess the problem could related to my system. I am using the new "default/linux/amd64/23.0/desktop/plasma/systemd" and have followed the newsletter to upgrade my system.
Comment 1 Xi 2024-03-26 07:03:25 UTC
Created attachment 888582 [details]
build.log
Comment 2 Joonas Niilola gentoo-dev 2024-04-05 13:33:01 UTC
Anything in dmesg?

What happens if you go to the build dir and try to manually call the command? This crash unfortunately doesn't tell much :\
Comment 3 Xi 2024-04-06 08:52:10 UTC
I tried nss-3.99 today and got a similar error.

In dmesg, I found these lines:

```
[  885.044742] shlibsign[144477]: segfault at 0 ip 0000000000000000 sp 00007ffc62369e98 error 14 in shlibsign[560a05c7c000+2000] likely on CPU 4 (core 0, socket 0)
[  885.044757] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[  885.046055] shlibsign[144474]: segfault at 0 ip 0000000000000000 sp 00007ffe04102948 error 14 in shlibsign[55745c408000+2000] likely on CPU 0 (core 0, socket 0)
[  885.046068] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[  885.048704] shlibsign[144473]: segfault at 0 ip 0000000000000000 sp 00007ffe3daedb38 error 14 in shlibsign[561a5d70b000+2000] likely on CPU 6 (core 2, socket 0)
[  885.048718] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[  885.053637] shlibsign[144476]: segfault at 0 ip 0000000000000000 sp 00007ffeca6d26b8 error 14 in shlibsign[55c3e6004000+2000] likely on CPU 4 (core 0, socket 0)
[  885.053650] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
```

How likely is it that my CPU is really broken while my system is still running?

I have nss-3.91 compiled successfully, and the last successful build was on 2023-9-30.
Comment 4 Xi 2024-04-06 08:53:13 UTC
Created attachment 889572 [details]
nss 3.99 build log

gcc 12, no lto
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-06 10:08:26 UTC
(In reply to Xi from comment #3)
> 
> How likely is it that my CPU is really broken while my system is still
> running?

Who said anything about broken CPUs?

Anyway, need someone to run the failing command manually in the builddir and get it to crash please.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-06 10:09:01 UTC
Please also share emerge --info.
Comment 7 Mart Raudsepp gentoo-dev 2024-04-06 18:54:55 UTC
Happening for 3.98 and 3.99 for me with clang-18. Didn't try earlier.

Crash backtrace of /tmp/portage/dev-libs/nss-3.98/work/nss-3.98/nss-.arm64/cmd/shlibsign/Linux6.6_aarch64_clang_glibc_PTH_64_OPT.OBJ/shlibsign
goes like this:

#0  0x0000000000000000 in ?? ()
#1  0x0000ffffb11a66ec in __do_fini () at /tmp/portage/sys-libs/compiler-rt-17.0.3/work/compiler-rt/lib/builtins/crtbegin.c:101
#2  0x0000ffffb40dcec8 [PAC] in _dl_call_fini (closure_map=closure_map@entry=0xaaab693d62f0) at dl-call_fini.c:43
#3  0x0000ffffb40e0974 in _dl_fini () at dl-fini.c:114
#4  0x0000ffffb3e1ef70 in ?? () from /usr/lib64/libc.so.6
#5  0x0000ffffb3e1f05c in exit () from /usr/lib64/libc.so.6
#6  0x0000ffffb3e08198 in ?? () from /usr/lib64/libc.so.6
#7  0x0000ffffb3e08278 in __libc_start_main () from /usr/lib64/libc.so.6
#8  0x0000aaab64533130 in _start ()


emerge --info:

Portage 3.0.54 (python 3.11.7-final-0, default/linux/arm64/23.0/desktop/gnome/systemd, gcc-14, glibc-2.39-r2, 6.6.0-asahi+ aarch64)
=================================================================
System uname: Linux-6.6.0-asahi+-aarch64-with-glibc2.39
KiB Mem:   198993696 total, 153618032 free
KiB Swap:          0 total,         0 free
Head commit of repository asahi: 462de15af8a71478fa31552e196053f4b8425867

sh bash 5.2_p26
ld GNU ld (Gentoo 2.41 p5) 2.41.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r1::gentoo
dev-build/cmake:           3.28.2::gentoo
dev-build/libtool:         2.4.7-r3::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.2.3::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r2::gentoo
dev-lang/python:           3.11.7::gentoo, 3.12.1_p1::gentoo
dev-lang/rust-bin:         1.74.1::gentoo
sys-apps/baselayout:       2.14-r2::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-apps/systemd:          254.10::gentoo
sys-devel/binutils:        2.41-r5::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.6::gentoo, 18.1.3::gentoo
sys-devel/gcc:             14.0.1_pre20240331::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             17.0.6::gentoo, 18.1.3::gentoo
sys-devel/llvm:            17.0.6::gentoo, 18.1.3::gentoo
sys-kernel/linux-headers:  6.7::gentoo (virtual/os-headers)
sys-libs/glibc:            2.39-r2::gentoo
Repositories:

gentoo
    location: /home/leio/gentoo/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1

asahi
    location: /var/db/repos/asahi
    sync-type: git
    sync-uri: https://github.com/chadmed/asahi-overlay.git
    masters: gentoo
    volatile: False

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://gentoo.osuosl.org/releases/arm64/binpackages/23.0/arm64

ACCEPT_KEYWORDS="arm64 ~arm64"
ACCEPT_LICENSE="@FREE"
AR="llvm-ar"
CBUILD="aarch64-unknown-linux-gnu"
CC="clang"
CFLAGS="-mcpu=apple-m2 -O3 -pipe -mbranch-protection=standard -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-default-version=4 -gdwarf-4 -frecord-gcc-switches -Werror=odr -Werror=strict-aliasing -flto=thin"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php8.3/ext-active/ /etc/php/cgi-php8.3/ext-active/ /etc/php/cli-php8.3/ext-active/ /etc/php/fpm-php8.3/ext-active/ /etc/php/phpdbg-php8.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXX="clang++"
CXXFLAGS="-mcpu=apple-m2 -O3 -pipe -mbranch-protection=standard -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-default-version=4 -gdwarf-4 -frecord-gcc-switches -Werror=odr -Werror=strict-aliasing -flto=thin"
DISTDIR="/home/distfiles"
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="-mcpu=apple-m2 -O3 -pipe -mbranch-protection=standard -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-default-version=4 -gdwarf-4 -frecord-gcc-switches -Werror=odr -Werror=strict-aliasing"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-mcpu=apple-m2 -O3 -pipe -mbranch-protection=standard -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-default-version=4 -gdwarf-4 -frecord-gcc-switches -Werror=odr -Werror=strict-aliasing"
GENTOO_MIRRORS="https://mirror.netcologne.de/gentoo/ http://gentoo.mirrors.ovh.net/gentoo-distfiles/ http://ftp.halifax.rwth-aachen.de/gentoo/"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-zpack-relative-relocs -flto=thin -Wl,--defsym=__gentoo_check_ldflags__=0"
LEX="flex"
LINGUAS="en et et_EE pl de"
MAKEOPTS="-j26"
OBJCOPY="llvm-objcopy"
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="/tmp"
RANLIB="llvm-ranlib"
RUSTFLAGS="-C linker-plugin-lto -C opt-level=3 -C target-cpu=apple-m2 -C link-arg=-Wl,-z,pack-relative-relocs"
SHELL="/bin/bash"
USE="X a52 aac acl acpi alsa arm64 bluetooth branding brotli bzip2 cairo cdda cdr clang colord crypt cups dbus dri dts dvdr eds encode evo exif flac flatpak gdbm gif gnome gnome-keyring gnome-online-accounts gnome-shell gpm gstreamer gtk gui iconv icu introspection ipv6 jpeg keyring lcms libnotify libtirpc lzma mad mng mp3 mp4 mpeg nautilus ncurses networkmanager nls ogg opengl openmp opus pam pango pcre pdf pipewire png policykit ppds pulseaudio readline screencast sdl seccomp sound spell ssl startup-notification svg sysprof systemd test-rust tiff tracker truetype udev udisks unicode upower usb vorbis vulkan wayland wxwidgets x264 xattr xcb xft xml xv zlib zstd" ADA_TARGET="gcc_12" 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_ARM="edsp v8 vfp vfp-d32 vfpv3 vfpv4" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en et" 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-3" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby33" VIDEO_CARDS="fbdev asahi dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, ARFLAGS, AS, ASFLAGS, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 8 Mart Raudsepp gentoo-dev 2024-04-06 18:57:56 UTC
To clarify - 3.98 was the already emerged ebuild copied over, so that succeeded to build back in 2024-03-17T00:57:04.
Since then llvm/clang was upgraded from 18.1.0 to 18.1.3; glibc was rebuilt with a newer gcc-14 snapshot since then, but it was 2.39-r2 already when the successful nss build happened.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-07 08:05:09 UTC
(In reply to Sam James from comment #6)
> Please also share emerge --info.

(leio points out this is in op's build.log, just at the end)
Comment 10 Xi 2024-04-13 09:05:38 UTC
Hi Sam,

I could not figure out which command to run in the builddir to reproduce that error. Can you give an example?

"emerge --info" is added by wgetpaste.
Comment 11 Joonas Niilola gentoo-dev 2024-04-15 08:04:47 UTC
I wonder if this is related to bug #916328
Comment 12 James Calligeros 2024-04-18 11:29:12 UTC
Compiling app-arch/xz-utils and sys-libs/zlib *both* with USE="static-libs" and using GCC as the toolchain seems to remedy this issue, but don't ask me why.

This is infinitely reproducible across multiple ~arm64 machines. Last time I tested, ISTR that using Clang/LLVM, even with USE="static-libs", still produced the segfault.
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-19 02:29:26 UTC
Consider me sniped. I'll look either today or over the weekend.
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-04-19 02:33:28 UTC
in the meantime: it would help if someone could give me some simple instructions to make it happen in a stage3, presumably involving that static-libs flip
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-02 06:09:52 UTC
(In reply to James Calligeros from comment #12)
> Compiling app-arch/xz-utils and sys-libs/zlib *both* with USE="static-libs"
> and using GCC as the toolchain seems to remedy this issue, but don't ask me
> why.
> 

If you're using LTO, static-libs means you get LTO across the library boundary too.
Comment 16 Mart Raudsepp gentoo-dev 2024-05-03 16:35:27 UTC
This started being fine for me after I:

* Applied patch from bug 787623 as a user patch to portage, in order to fix gdb usage on my system
* rebuilt glibc with it (and glib, folks, gtk3 and gtk4 to test if gdb works now)
* rebuild compiler-rt:17 and upgrade compiler-rt:18 together with the rest of llvm:18 stack from 18.1.3 to 18.1.4, in order to truly fix gdb as compiler-rt ships object files that are static linked as well
* Rebuilt xz-utils in the hope it helps for nss - it didn't yet
* Unrelatedly upgraded some perl and ruby stuff, zlib as part of it; iirc nss was still crashing build after this point
* Picked gpgme and libgcrypt to rebuild as well (libgcrypt was from 1.10.3-r0 to -r2, but there don't appear any relevant changes as I use lld and am on arm64)
* After this, nss compilation succeeded.

I don't know if the debuglink fixes are related, or more about clang bug fix release + gpgme/libcrypt rebuild did it, but I can upgrade firefox now, yay.
Comment 17 Xi 2024-05-11 03:56:09 UTC
After read Mart's comment, I did the following on my system, and I can build "dev-libs/nss-3.99" on my system now.

- emerge -1 app-crypt/gpgme libcrypt
- emerge -1 xz-utils

I don't have `compiler-rt:18` on my system, as they are masked for amd64. Also, I did the above commands after I did a world update on my system, so I am not sure how many other package updates are related to this behaviour change.
Comment 18 Simon Maurer 2024-07-19 16:06:41 UTC
It looks like the problem is in nss/cmd/shlibsign/shlibsign.c with the PR_UnloadLibrary call. But if the NSS_DISABLE_UNLOAD environment variable is set, this call will be omitted. 
So adding the line 
export NSS_DISABLE_UNLOAD=1
to the multilib_src_compile function in the ebuild file fixed the bug for me.