Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 908809 - x11-libs/qwt:6[qt6]: sandbox causes qmake to fail: Project ERROR: Cannot run compiler 'g++'
Summary: x11-libs/qwt:6[qt6]: sandbox causes qmake to fail: Project ERROR: Cannot run ...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-18 22:52 UTC by Andrew Udvare
Modified: 2023-10-21 06:27 UTC (History)
4 users (show)

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


Attachments
build log (build.log,2.61 KB, text/x-log)
2023-06-18 22:52 UTC, Andrew Udvare
Details
coredump (qmake6.coredump.zst,357.09 KB, application/zstd)
2023-06-22 15:42 UTC, Andrew Udvare
Details
Dockerfile (Dockerfile,1.70 KB, text/plain)
2023-06-24 06:43 UTC, Andrew Udvare
Details
fix sys-apps/sandbox-2.35 QA-notice (sandbox-2.35.patch,5.47 KB, patch)
2023-07-10 17:35 UTC, gto7052
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Udvare 2023-06-18 22:52:43 UTC
Stack trace:


Core was generated by `/usr/lib64/qt6/bin/qmake -makefile QMAKE_AR="x86_64-pc-linux-gnu-ar cqs" QMAKE_'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fe86ac98410 in do_lookup_x (undef_name=undef_name@entry=0x7fe86ac6f6de "strstr", new_hash=new_hash@entry=479451991,
    old_hash=old_hash@entry=0x7ffce152fd38, ref=0x7fe86ac6edf0, result=result@entry=0x7ffce152fd40, scope=<optimized out>,
    i=<optimized out>, version=0x7fe86a48fc78, flags=1, skip=<optimized out>, type_class=1, undef_map=0x7fe86ac8d0e0) at dl-lookup.c:445
445     dl-lookup.c: No such file or directory.
(ins)(gdb) bt
#0  0x00007fe86ac98410 in do_lookup_x (undef_name=undef_name@entry=0x7fe86ac6f6de "strstr", new_hash=new_hash@entry=479451991,
    old_hash=old_hash@entry=0x7ffce152fd38, ref=0x7fe86ac6edf0, result=result@entry=0x7ffce152fd40, scope=<optimized out>,
    i=<optimized out>, version=0x7fe86a48fc78, flags=1, skip=<optimized out>, type_class=1, undef_map=0x7fe86ac8d0e0) at dl-lookup.c:445
#1  0x00007fe86ac98f37 in _dl_lookup_symbol_x (undef_name=0x7fe86ac6f6de "strstr", undef_map=undef_map@entry=0x7fe86ac8d0e0,
    ref=ref@entry=0x7ffce152fdd0, symbol_scope=<optimized out>, version=0x7fe86a48fc78, type_class=type_class@entry=1, flags=1,
    skip_map=0x7fe86ac9f527 <_dl_fixup+631>) at dl-lookup.c:776
#2  0x00007fe86ac9f3b2 in _dl_fixup (l=0x7fe86ac8d0e0, reloc_arg=73) at dl-runtime.c:95
#3  0x00007fe86aca168a in _dl_runtime_resolve_xsavec () at ../sysdeps/x86_64/dl-trampoline.h:130
#4  0x00007ffce1530a20 in ?? ()
#5  0x00007ffce1530a18 in ?? ()
#6  0x00007fe86ac7f06f in ?? () from /usr/lib64/qt6/bin/../../libsandbox.so
#7  0x00007fe86ac7ee0d in ?? () from /usr/lib64/qt6/bin/../../libsandbox.so
#8  0x00007fe86a17464b in ?? () from /usr/lib64/qt6/bin/../../libc.so.6
#9  0x00007fe86a0ad058 in ?? () from /usr/lib64/qt6/bin/../../libc.so.6
#10 0x00007fe86ac90489 in __GI__dl_catch_exception (exception=exception@entry=0x7ffce15309c0, operate=0x7fe86a0ad040,
    args=0x7ffce1530a60) at dl-catch.c:237
#11 0x00007fe86ac905af in _dl_catch_error (objname=0x7ffce1530920, errstring=0x7ffce1530ad0, mallocedp=0x7ffce1530a17,
    operate=<optimized out>, args=<optimized out>) at dl-catch.c:256
#12 0x00007fe86a0ac987 in ?? () from /usr/lib64/qt6/bin/../../libc.so.6
#13 0x00007fe86a0ad11e in dlvsym () from /usr/lib64/qt6/bin/../../libc.so.6
#14 0x00007fe86ac7666e in get_dlsym (symname=0x7fe86ac7f06f "execv", symver=0x7fe86ac7ee63 "GLIBC_2.2.5")
    at /var/tmp/portage/sys-apps/sandbox-2.31/work/sandbox-2.31/libsandbox/wrappers.c:53
#15 0x00007fe86ac79ba9 in sb_unwrapped_execv_DEFAULT (argv=0x55a6e364c6a0, path=0x55a6e3370610 "/bin/sh")
    at /var/tmp/portage/sys-apps/sandbox-2.31/work/sandbox-2.31/libsandbox/wrapper-funcs/__wrapper_exec.c:259
#16 execv_DEFAULT (path=0x55a6e3370610 "/bin/sh", argv=0x55a6e364c6a0)
    at /var/tmp/portage/sys-apps/sandbox-2.31/work/sandbox-2.31/libsandbox/wrapper-funcs/__wrapper_exec.c:329
#17 0x00007fe86a98ec0d in qt_safe_execv (argv=<optimized out>, path=<optimized out>)
    at /var/tmp/portage/dev-qt/qtbase-6.5.1-r1/work/qtbase-everywhere-src-6.5.1_build/include/QtCore/6.5.1/QtCore/private/../../../../../../qtbase-everywhere-src-6.5.1/src/corelib/kernel/qcore_unix_p.h:289
#18 QProcessPrivate::execChild (this=0x55a6e364bbc0, workingDir=0x55a6e364ba40 "/usr/lib64/qt6/mkspecs/features", argv=0x55a6e364c6a0,
    envp=0x0) at /var/tmp/portage/dev-qt/qtbase-6.5.1-r1/work/qtbase-everywhere-src-6.5.1/src/corelib/io/qprocess_unix.cpp:547
#19 0x00007fe86a98ec6e in operator() (__closure=<optimized out>)
    at /var/tmp/portage/dev-qt/qtbase-6.5.1-r1/work/qtbase-everywhere-src-6.5.1/src/corelib/io/qprocess_unix.cpp:461
#20 operator() (lambda=<optimized out>, __closure=0x0)
    at /var/tmp/portage/dev-qt/qtbase-6.5.1-r1/work/qtbase-everywhere-src-6.5.1/src/corelib/io/qprocess_unix.cpp:464
#21 _FUN () at /var/tmp/portage/dev-qt/qtbase-6.5.1-r1/work/qtbase-everywhere-src-6.5.1/src/corelib/io/qprocess_unix.cpp:466
#22 0x00007fe86a131840 in clone () from /usr/lib64/qt6/bin/../../libc.so.6

Reproducible: Always

Steps to Reproduce:
1. USE=qt6 emerge -1 x11-libs/qwt:6
Actual Results:  
Fails to build.

Expected Results:  
Should build.

Portage 3.0.48.1 (python 3.11.4-final-0, default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr, gcc-13, glibc-2.37-r3, 6.3.8-gentoo-limelight x86_64)
=================================================================
System uname: Linux-6.3.8-gentoo-limelight-x86_64-11th_Gen_Intel-R-_Core-TM-_i9-11900K_@_3.50GHz-with-glibc2.37
KiB Mem:    65708332 total,  46450620 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Sun, 18 Jun 2023 21:02:08 +0000
Head commit of repository gentoo: 2bf37f258887fcba6bc8af705140972186182762

Timestamp of repository brave-overlay: Wed, 14 Jun 2023 20:01:54 +0000
Head commit of repository brave-overlay: 3175fb13cb5fb56bd0eaa258027338ff0d851735

Head commit of repository guru: ae2c75b7fd693a6291305762735315c14e1b9a77

Timestamp of repository menelkir: Sun, 18 Jun 2023 21:02:00 +0000
Head commit of repository menelkir: ec2b36851fa8a56b26a236a9265465b0dcbaf1b7

Timestamp of repository pentoo: Sun, 18 Jun 2023 21:01:56 +0000
Head commit of repository pentoo: 361dceef3062e60b00855ff6621a64df9c9a05c8

Timestamp of repository steam-overlay: Sat, 17 Jun 2023 10:17:28 +0000
Head commit of repository steam-overlay: 6d66cb6aaaeceafa8b4df65009bc5f851e6e7b01

Head commit of repository tatsh-overlay: f59cebd4d7eb61bd64227c706618e48249438392

sh bash 5.2_p15-r3
ld GNU ld (Gentoo 2.40 p5) 2.40.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r3::gentoo
dev-java/java-config:      2.3.1-r1::gentoo
dev-lang/perl:             5.36.1-r2::gentoo
dev-lang/python:           3.10.12::gentoo, 3.11.4::gentoo, 3.12.0_beta2::gentoo
dev-lang/rust:             1.69.0-r1::gentoo
dev-util/cmake:            3.26.4-r1::gentoo
dev-util/meson:            1.1.1::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/sandbox:          2.31::gentoo
sys-apps/systemd:          253.5::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:           15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/gcc:             13.1.1_p20230527::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo, 16.0.6::gentoo
sys-devel/llvm:            14.0.6-r4::gentoo, 15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/make:            4.4.1-r1::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://anongit.gentoo.org/git/repo/sync/gentoo.git
    priority: -1000
    volatile: False
    sync-git-verify-commit-signature: no

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

crossdev
    location: /var/db/repos/crossdev
    masters: gentoo
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: git+ssh://git@git.gentoo.org/repo/proj/guru.git
    masters: gentoo
    volatile: False
    sync-git-verify-commit-signature: no

menelkir
    location: /var/db/repos/menelkir
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/menelkir.git
    masters: gentoo
    volatile: False

pentoo
    location: /var/db/repos/pentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/pentoo.git
    masters: gentoo
    volatile: False

rcvpn
    location: /var/db/repos/rcvpn
    masters: gentoo
    volatile: False

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

tatsh-overlay
    location: /var/db/repos/tatsh
    sync-type: git
    sync-uri: https://github.com/Tatsh/tatsh-overlay.git
    masters: gentoo
    volatile: False
    sync-git-verify-commit-signature: no

Installed sets: @admin, @android, @bashcomp, @cdr, @charles, @chrome, @cups, @dbeaver, @emulators, @exfat, @firefox, @fonts, @gimp, @git, @i3, @ibus, @kde, @kernel, @kodi, @libimobiledevice, @libreoffice, @media, @misc, @mlocate, @mupen64plus, @nfs, @pass, @portage-utilities, @python, @qemu, @rar, @retroarch, @ringcentral, @sm64, @steam, @stepmania, @thunderbird, @tmux, @vim, @virtualbox, @vlc, @vscode, @wine, @x11, @xirvik-vpn, @yt-dlp
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -flto -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /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/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -flto -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--jobs 17 --load-average 17 --quiet-build=y --usepkg --verbose-conflicts --buildpkg-exclude 'acct-*/* app-arch/rar app-emulation/virtualbox-extpack-oracle app-emulation/virtualbox-modules */*-bin dev-util/intel-ocl-sdk games-util/steam-launcher media-fonts/* media-video/magewell-pro-capture media-video/makemkv net-im/ripcord sys-kernel/linux-firmware sys-kernel/*-sources virtual/* media-video/cxadc *-drivers/*'"
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 -flto -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live cgroup clean-logs compressdebug 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 qa-unresolved-soname-deps sandbox sfperms splitdebug strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync warn-on-large-env xattr"
FFLAGS="-O2 -flto -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
GENTOO_MIRRORS="http://gentoo.osuosl.org/  http://www.gtlib.gatech.edu/pub/gentoo https://mirrors.rit.edu/gentoo/"
INSTALL_MASK="/etc/avahi/services/sftp-ssh.service /etc/conf.d /etc/cron.daily /etc/cron.monthly /etc/cron.weekly /etc/dracut.conf /etc/grub.d /etc/init.d /etc/modules-load.d/ddccontrol-i2c-dev.conf /usr/lib/modules-load.d/fwupd-msr.conf /usr/lib/modules-load.d/joycond.conf /usr/lib/rc"
LANG="en_GB.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
LINGUAS="en en_GB en_US"
MAKEOPTS="--jobs=17 --load-average=17"
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"
SHELL="/bin/bash"
USE="X a52 aac aacs acl acpi activities aio alsa amd64 aptx avahi bash-completion bluetooth bluray branding bzip2 cairo cdda cddb cdio cdr cjk clang cli colord crypt cups curl dav1d dbus declarative dri dts dvb dvd dvdr egl encode exif faudio ffmpeg flac fluidsynth fortran gamepad gdbm gif gles2 gpm gsm gstreamer gui hardened heif hwaccel ibus iconv icu idn ipv6 jack jemalloc joystick jpeg jpeg2k kde kwallet lame lcms ldac libass libcaca libnotify libretro libtirpc lm-sensors lto lv2 lvm lz4 lzma mad man matroska mng mod modplug mp3 mp4 mpeg multilib ncurses nls nptl nvenc ogg opencl opengl openmp opus pam pango pcre pdf pgo pipewire plasma png policykit ppds pulseaudio qml qt5 qt6 rar readline samba screencast sdl seccomp semantic-desktop snappy sound speex spell ssl startup-notification svg syslog system-av1 system-binutils system-boost system-bootloader system-cmark system-crontab system-ffmpeg system-harfbuzz system-heimdal system-info system-ipxe system-jpeg system-jsoncpp system-lcms system-leveldb system-libcxx system-libevent system-libs system-libvpx system-libyaml system-llvm system-lua system-lz4 system-mathjax system-mesa system-mitkrb5 system-numpy system-png system-python system-qemu system-seabios system-sqlite system-ssl system-tbb system-webp system-wfconfig system-wide system-wlroots system-zlib systemd taglib test-rust theora threads tiff tpm truetype twolame udev udisks unicode upower usb v4l vaapi vcd vdpau vim-syntax vlc vorbis vpx vulkan wavpack wayland webengine webp widgets wmf wxwidgets x264 x265 xattr xcb xft xinerama xml xpm xv xvid xxhash zeroconf zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2021" 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 avx512f avx512dq avx512cd avx512bw avx512vl avx512vbmi f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 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="evdev libinput joystick wacom" KERNEL="linux" L10N="en en-GB en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" 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" QEMU_SOFTMMU_TARGETS="ppc x86_64" RUBY_TARGETS="ruby31" VIDEO_CARDS="nvidia v4l" 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, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Andrew Udvare 2023-06-18 22:52:58 UTC
Created attachment 864179 [details]
build log
Comment 2 Greg Kubaryk 2023-06-19 02:59:23 UTC
Was unable to reproduce, maybe an LTO problem?
Comment 3 Andrew Udvare 2023-06-19 04:35:13 UTC
I built qtbase, sandbox, and even glibc without LTO and the issue still occurs. This seems like a sandbox issue:

qmake6 at some point is running `/bin/sh -c 'g++ -E /usr/lib64/qt6/mkspecs/features/data/macros.cpp  2>/dev/null'`. This triggers sandbox to look up the execv symbol with sb_unwrapped_execv_DEFAULT(). dlvsym fails and _dl_catch_error is called to handle the error. The error handler eventually segfaults during a recursive call to do_lookup_x. The segfault is within glibc after its error handling (__GI__dl_catch_exception, etc).

dlvsym call in sandbox https://gitweb.gentoo.org/proj/sandbox.git/tree/libsandbox/wrappers.c#n53
do_lookup_x https://github.com/bminor/glibc/blob/master/elf/dl-lookup.c#L338
Comment 4 Andrew Udvare 2023-06-22 15:42:28 UTC
Created attachment 864419 [details]
coredump
Comment 5 Mike Gilbert gentoo-dev 2023-06-22 16:46:50 UTC
Does the build succeed with FEATURES="-sandbox -usersandbox"?
Comment 6 Andrew Udvare 2023-06-23 00:34:53 UTC
(In reply to Mike Gilbert from comment #5)
> Does the build succeed with FEATURES="-sandbox -usersandbox"?

Yes.
Comment 7 Mike Gilbert gentoo-dev 2023-06-23 14:16:36 UTC
I am unable to reproduce this.
Comment 8 Andrew Udvare 2023-06-23 18:54:13 UTC
This really only started happening after getting my machines to use LTO for every possible package (I set -flto in flags and then ran emerge -e @world). I only excluded ones that are not yet fixed. My config (make.conf variables are already posted):

/etc/portage/env/no-lto:

CFLAGS="-O2 -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
CXXFLAGS="${CFLAGS}"

/etc/portage/package.env/no-lto:

app-crypt/efitools no-lto # https://bugs.gentoo.org/908813
app-emulation/virtualbox no-lto # https://bugs.gentoo.org/908814
app-shells/mcfly no-lto # https://bugs.gentoo.org/854867
dev-python/cryptography no-lto  # https://bugs.gentoo.org/903908
dev-qt/qtscript no-lto # https://bugs.gentoo.org/652158
media-sound/guitarix no-lto # https://bugs.gentoo.org/860861
media-sound/musescore no-lto # https://bugs.gentoo.org/908808
media-video/rav1e no-lto # https://bugs.gentoo.org/908815
sys-apps/ripgrep-all no-lto # https://bugs.gentoo.org/863626
Comment 9 Andrew Udvare 2023-06-24 06:43:51 UTC
Created attachment 864511 [details]
Dockerfile

I was able to reproduce this bug in a Docker container. The Dockerfile sets up the image and then builds a 'build.sh' script that should be run.

$ # download Dockerfile here, named Dockerfile
$ docker build -t bug908880
$ docker run -it bug908880:latest
$ ./build.sh

Also qtbase[cups] is *not* pulling in net-print/cups like it should be.
Comment 10 Mike Gilbert gentoo-dev 2023-06-25 00:07:53 UTC
Thanks. I'll give it a spin, though I will need to adjust the cpu flags to work on my old AMD Phenom processor.
Comment 11 Mike Gilbert gentoo-dev 2023-06-26 01:55:07 UTC
I ran similar steps in a systemd-nspawn container, and was unable to reproduce the problem.

As previously mentioned, I did need to tweak CPU_FLAGS_X86 to match my CPU. As well, -march=native would enable different instructions on my system. It is possible this plays some role.

For the record, here is my make.conf from the container:

COMMON_FLAGS="-O2 -flto -ftree-vectorize -ggdb -march=native -mtune=native -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*"
INPUT_DEVICES="evdev libinput"
L10N="en en_US"
LINGUAS="en en_US"
USE="lto qt6"
CPU_FLAGS_X86="3dnow 3dnowext mmx mmxext popcnt sse sse2 sse3 sse4a"
MAKEOPTS="-j6"
FEATURES="-network-sandbox"
Comment 12 Andrew Udvare 2023-06-26 15:14:00 UTC
This is definitely a CPU issue. The problem is figuring out which package and flag is causing the issue.

On an older machine with these settings I did not get the same issue.

CFLAGS="-O2 -flto -ftree-vectorize -march=native -mtune=native -pipe"
CXXFLAGS="-O2 -flto -ftree-vectorize -march=native -mtune=native -pipe"
CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3"

I successfully built sys-apps/sandbox, qwt:6[qt5,qt6] (in that order) with the above settings.
Comment 13 Andrew Udvare 2023-06-26 15:28:23 UTC
Renamed this ticket since the qmake6 crash was caused by -ftree-vectorize on sys-apps/sandbox. I am keeping that flag removed from sandbox permanently.

This bug can be considered somewhat of a duplicate of https://bugs.gentoo.org/show_bug.cgi?id=908807 (graphviz[qt5] having the same issue because it find Qt 6's qmake first).
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-26 15:29:32 UTC
(In reply to Andrew Udvare from comment #13)
> Renamed this ticket since the qmake6 crash was caused by -ftree-vectorize on
> sys-apps/sandbox. I am keeping that flag removed from sandbox permanently.
> 

It's unclear to me if that's the same issue as your original dlsym problem. In any case, that shouldn't happen.

> This bug can be considered somewhat of a duplicate of
> https://bugs.gentoo.org/show_bug.cgi?id=908807 (graphviz[qt5] having the
> same issue because it find Qt 6's qmake first).

Let's leave that other bug purely for the Qt 6 automagic which is an issue in itself.
Comment 15 Andrew Udvare 2023-06-26 18:54:02 UTC
Here is a longer explanation of what is happening but I do not yet have a solution.

qmake6 is running its normal scripts to check the system. It lands here: https://github.com/qt/qtbase/blob/f4a80552c2784eaa0659acd12df7a865aeb7ebec/mkspecs/features/toolchain.prf#L38 which runs `g++ -E /usr/lib64/qt6/mkspecs/features/data/macros.cpp  2>/dev/null`. The expected output is generated (I tested this by setting its output to another file).

Only when under sandbox, a cc1plus subprocess exits with SIGPIPE. This in turn makes GCC return non-zero (-1 when it gets back to qmake).

The cc1plus subprocess stops in c_common_finish (line 1311 for gcc-13.1.1_p20230527, https://github.com/gcc-mirror/gcc/blob/master/gcc/c-family/c-opts.cc#L1319 ). The call to fclose() fails.

Stack trace:

Thread 5.1 "cc1plus" received signal SIGPIPE, Broken pipe.
0x00007ffff7b5db80 in write () from /usr/lib64/libc.so.6
(ins)(gdb) bt
#0  0x00007ffff7b5db80 in write () from /usr/lib64/libc.so.6
#1  0x00007ffff7ae5185 in _IO_file_write () from /usr/lib64/libc.so.6
#2  0x00007ffff7ae44c9 in ?? () from /usr/lib64/libc.so.6
#3  0x00007ffff7ae6229 in _IO_do_write () from /usr/lib64/libc.so.6
#4  0x00007ffff7ae5b50 in _IO_file_close_it () from /usr/lib64/libc.so.6
#5  0x00007ffff7ad892b in fclose () from /usr/lib64/libc.so.6
#6  0x000000000191f7cd in c_common_finish ()
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/c-family/c-opts.cc:1311
#7  0x00000000018d3b23 in finalize (no_backend=true)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2031
#8  do_compile (no_backend=true) at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2138
#9  toplev::main (this=this@entry=0x7fffffffd056, argc=<optimized out>, argv=<optimized out>)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2281
#10 0x00000000018d2dbb in main (argc=<optimized out>, argv=<optimized out>)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/main.cc:39

The disassembly at where it stopped (I do not know why I cannot get glibc code to show in GDB despite having the source unpacked by Portage and built with -ggdb):

Dump of assembler code for function write:
   0x00007ffff7b5db70 <+0>:     cmp    BYTE PTR [rip+0xdda61],0x0        # 0x7ffff7c3b5d8 <__libc_single_threaded>
   0x00007ffff7b5db77 <+7>:     je     0x7ffff7b5db90 <write+32>
   0x00007ffff7b5db79 <+9>:     mov    eax,0x1
   0x00007ffff7b5db7e <+14>:    syscall
=> 0x00007ffff7b5db80 <+16>:    cmp    rax,0xfffffffffffff000
   0x00007ffff7b5db86 <+22>:    ja     0x7ffff7b5dbe0 <write+112>

The return value from the write syscall is -32 (in $rax).

This cmp instruction is from https://github.com/bminor/glibc/blob/4290aed05135ae4c0272006442d147f2155e70d7/sysdeps/unix/sysv/linux/sysdep.h#L27C1-L28C40 , assuming write is actually _dl_write https://github.com/bminor/glibc/blob/4290aed05135ae4c0272006442d147f2155e70d7/sysdeps/unix/sysv/linux/dl-write.c#L24 .

#define INTERNAL_SYSCALL_ERROR_P(val) \
  ((unsigned long int) (val) > -4096UL)
Comment 16 Andrew Udvare 2023-06-28 13:12:35 UTC
With proper symbols, the stack trace:

Thread 5.1 "cc1plus" received signal SIGPIPE, Broken pipe.
0x00007ffff7b68b80 in __GI___libc_write (fd=1, buf=0x26d8670, nbytes=378) at ../sysdeps/unix/sysv/linux/write.c:26
26        return SYSCALL_CANCEL (write, fd, buf, nbytes);
(ins)(gdb) bt
#0  0x00007ffff7b68b80 in __GI___libc_write (fd=1, buf=0x26d8670, nbytes=378) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x00007ffff7af0185 in _IO_new_file_write (f=0x7ffff7c3f780 <_IO_2_1_stdout_>, data=0x26d8670, n=378) at fileops.c:1180
#2  0x00007ffff7aef4c9 in new_do_write (fp=0x7ffff7c3f780 <_IO_2_1_stdout_>,
    data=0x26d8670 "# 0 \"/usr/lib64/qt6/mkspecs/features/data/macros.cpp\"\n# 0 \"<built-in>\"\n# 0 \"<command-line>\"\n# 1 \"/usr/include/stdc-predef.h\" 1 3 4\n# 0 \"<command-line>\" 2\n# 1 \"/usr/lib64/qt6/mkspecs/features/data/macr"..., to_do=to_do@entry=378)
    at /var/tmp/portage/sys-libs/glibc-2.37-r3/work/glibc-2.37/libio/libioP.h:946
#3  0x00007ffff7af1229 in _IO_new_do_write (fp=fp@entry=0x7ffff7c3f780 <_IO_2_1_stdout_>, data=<optimized out>, to_do=378)
    at fileops.c:425
#4  0x00007ffff7af0b50 in _IO_new_file_close_it (fp=fp@entry=0x7ffff7c3f780 <_IO_2_1_stdout_>) at fileops.c:135
#5  0x00007ffff7ae392b in _IO_new_fclose (fp=0x7ffff7c3f780 <_IO_2_1_stdout_>) at iofclose.c:53
#6  0x0000000000803bfa in c_common_finish ()
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/c-family/c-opts.cc:1311
#7  0x00000000014931ff in finalize (no_backend=true)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2031
#8  do_compile (no_backend=true) at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2138
#9  toplev::main (this=this@entry=0x7fffffffd056, argc=<optimized out>, argc@entry=11, argv=<optimized out>, argv@entry=0x7fffffffd188)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/toplev.cc:2281
#10 0x000000000149494b in main (argc=11, argv=0x7fffffffd188)
    at /var/tmp/portage/sys-devel/gcc-13.1.1_p20230527/work/gcc-13-20230527/gcc/main.cc:39

I cannot reproduce the issue by passing the GCC command to sandbox. It will exit normally. Only when sandbox is involved and the path is sandbox -> qmake -> gcc -> cc1plus does it fail.

When I put together a Dockerfile without -ftree-vectorize but with -flto and built @world, everything worked. My flags are now:

-O2 -flto=auto -ggdb -march=native -mtune=native -pipe

About 1/3 of my system was built with these flags (emerge -e1 qwt:6 media-gfx/graphviz), but the issue continues. I will consider a full rebuild, and possibly a full rebuild without -flto. Prior to this issue I did not have -flto set globally and that's when qwt:6 built successfully with sandbox enabled on my real machine (and not inside container).
Comment 17 Andrew Udvare 2023-06-28 13:13:42 UTC
Core dump compressed with zstd: https://chunk.io/Tatsh/7a0714c9221f4cc194afba6233e38df6
Comment 18 Andrew Udvare 2023-06-28 13:39:45 UTC
Clang gets the same error:

Thread 4.1 "clang++" received signal SIGPIPE, Broken pipe.
[Switching to Thread 0x7ffff7dc7f40 (LWP 13229)]
0x00007fffebb20b80 in __GI___libc_write (fd=1, buf=0x555555658d10, nbytes=718) at ../sysdeps/unix/sysv/linux/write.c:26
26        return SYSCALL_CANCEL (write, fd, buf, nbytes);

(ins)(gdb) bt
#0  0x00007fffebb20b80 in __GI___libc_write (fd=1, buf=0x555555658d10, nbytes=718) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x00007fffed03f640 in llvm::raw_fd_ostream::write_impl (this=0x55555561ce80,
    Ptr=0x555555658d10 "# 1 \"/usr/lib64/qt6/mkspecs/features/data/macros.cpp\"\n# 1 \"<built-in>\" 1\n# 1 \"<built-in>\" 3\n# 438 \"<built-in>\" 3\n# 1 \"<command line>\" 1\n# 1 \"<built-in>\" 2\n# 1 \"/usr/include/gentoo/fortify.h\" 1\n# 3 \"/u"..., Size=718)
    at /var/tmp/portage/sys-devel/llvm-16.0.6/work/llvm/lib/Support/raw_ostream.cpp:768
#2  0x00007fffed03fefa in llvm::raw_ostream::flush (this=0x55555561ce80)
    at /var/tmp/portage/sys-devel/llvm-16.0.6/work/llvm/include/llvm/Support/raw_ostream.h:187
#3  llvm::raw_fd_ostream::~raw_fd_ostream (this=0x55555561ce80, __in_chrg=<optimized out>)
    at /var/tmp/portage/sys-devel/llvm-16.0.6/work/llvm/lib/Support/raw_ostream.cpp:668
#4  0x00007fffed03ffc9 in llvm::raw_fd_ostream::~raw_fd_ostream (this=0x55555561ce80, __in_chrg=<optimized out>)
...
Comment 19 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-28 13:43:22 UTC
We need to know what's on the other side of the pipe which dies, SIGPIPE is ok
Comment 20 Andrew Udvare 2023-06-28 14:07:03 UTC
What else can I do in the debugger?

My current general workflow to get data:

set follow-fork-mode child
set detach-on-fork no
b execv_DEFAULT
r
Comment 21 Andrew Udvare 2023-06-28 15:36:28 UTC
Revising title because USE=qt5 is not necessary to trigger the error.
Comment 22 gto7052 2023-07-10 17:32:19 UTC
I'd be interested if the attached patch which adressing sys-apps/sandbox-2.35 maybe fixes this issue. Installing sandbox-2.35 generated several possibly severe QA-notices here:

* /tmp/portage/sys-apps/sandbox-2.35/work/sandbox-2.35/src/environ.c:211:19: warning: the comparison will always evaluate as ‘true’ for the address of ‘work_dir’ will never be NULL [-Waddress]

* /tmp/portage/sys-apps/sandbox-2.35/work/sandbox-2.35/libsandbox/canonicalize.c:113:41: warning: passing argument 2 to 'restrict'-qualified parameter aliases with argument 1 [-Wrestrict]

* /tmp/portage/sys-apps/sandbox-2.35/work/sandbox-2.35/libsandbox/libsandbox.c:144:9: warning: passing argument 2 to 'restrict'-qualified parameter aliases with argument 1 [-Wrestrict]

Depending on cpu/compiler version, code like readlink(x,x,sizeof(x)) could lead to undefined behavior because source and destination buffers overlap.
Comment 23 gto7052 2023-07-10 17:35:28 UTC
Created attachment 865353 [details, diff]
fix sys-apps/sandbox-2.35 QA-notice

The proposed patch; it was also sent to the sandbox maintainers.
Comment 24 Andrew Udvare 2023-07-11 10:26:42 UTC
Tried the above patch on sandbox and got the same result.
Comment 25 Andrew Udvare 2023-07-18 06:38:19 UTC
Tried with the newest sandbox 2.37 and the GCC subprocess (under qmake6) no longer crashes, but it still gives unexpected empty output.
Comment 26 Larry the Git Cow gentoo-dev 2023-10-21 06:22:38 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9152c25f592db19e2d6f6ab0aab991a463503a34

commit 9152c25f592db19e2d6f6ab0aab991a463503a34
Author:     Ionen Wolkens <ionen@gentoo.org>
AuthorDate: 2023-10-21 05:46:22 +0000
Commit:     Ionen Wolkens <ionen@gentoo.org>
CommitDate: 2023-10-21 06:21:50 +0000

    dev-qt/qtbase: fix qsb and qmake with sandbox
    
    Also add to 6.5.3, while the issue has been less prominent in
    6.5.x, there has been users that ran into issues with older
    versions, and is needed for stable users.
    
    See bug #915695 for details, the others are essentially duplicates
    which are hopefully fixed too (please report if still issues given
    I could never reproduce myself and cannot confirm).
    
    Closes: https://bugs.gentoo.org/908809
    Closes: https://bugs.gentoo.org/908816
    Closes: https://bugs.gentoo.org/913493
    Closes: https://bugs.gentoo.org/915695
    Thanks-to: vowstar
    Thanks-to: Mike Gilbert <floppym@gentoo.org>
    Signed-off-by: Ionen Wolkens <ionen@gentoo.org>

 .../qtbase-6.5.3-forkfd-childstack-size.patch      | 27 ++++++++++++++++++++++
 ...{qtbase-6.5.3.ebuild => qtbase-6.5.3-r1.ebuild} |  1 +
 ...{qtbase-6.6.0.ebuild => qtbase-6.6.0-r1.ebuild} |  1 +
 3 files changed, 29 insertions(+)