``` $ echo 'int main(){}' | clang -x c - -fsanitize=memory -o /dev/null /usr/bin/x86_64-gentoo-linux-musl-ld.bfd: /usr/lib/llvm/16/bin/../../../../lib/clang/16/lib/linux/libclang_rt.msan-x86_64.a(msan_interceptors.cpp.o): in function `__interceptor_getrlimit64': (.text+0x5eea): undefined reference to `__sanitizer::struct_rlimit64_sz' /usr/bin/x86_64-gentoo-linux-musl-ld.bfd: /usr/lib/llvm/16/bin/../../../../lib/clang/16/lib/linux/libclang_rt.msan-x86_64.a(msan_interceptors.cpp.o): in function `__interceptor_prlimit64': (.text+0x60f9): undefined reference to `__sanitizer::struct_rlimit64_sz' /usr/bin/x86_64-gentoo-linux-musl-ld.bfd: (.text+0x6126): undefined reference to `__sanitizer::struct_rlimit64_sz' /usr/bin/x86_64-gentoo-linux-musl-ld.bfd: (.text+0x61b4): undefined reference to `__sanitizer::struct_rlimit64_sz' clang-16: error: linker command failed with exit code 1 (use -v to see invocation) ``` ---- Portage 3.0.47 (python 3.11.3-final-0, default/linux/amd64/17.0/musl/hardened, gcc-13, musl-1.2.4, 6.1.28-gentoo-dist-hardened x86_64) ================================================================= System uname: Linux-6.1.28-gentoo-dist-hardened-x86_64-AMD_Ryzen_9_3950X_16-Core_Processor-with-libc KiB Mem: 65746300 total, 19621932 free KiB Swap: 8290300 total, 7748464 free Timestamp of repository gentoo: Wed, 17 May 2023 09:16:55 +0000 sh bash 9999 ld GNU ld (Gentoo 2.40 p5) 2.40.0 app-misc/pax-utils: 1.3.7::gentoo app-shells/bash: 9999::gentoo dev-lang/perl: 5.36.1-r1::gentoo dev-lang/python: 3.9.16::gentoo, 3.10.11::gentoo, 3.11.3::gentoo dev-util/cmake: 3.26.3::gentoo dev-util/meson: 1.1.0::gentoo sys-apps/baselayout: 2.13-r1::gentoo sys-apps/openrc: 0.47.1::gentoo sys-apps/sandbox: 2.30-r1::gentoo sys-devel/autoconf: 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-r1::gentoo, 16.0.3::gentoo sys-devel/gcc: 10.4.1_p20230510::gentoo, 11.3.1_p20230511::gentoo, 13.1.1_p20230513::gentoo, 14.0.0_pre20230514::gentoo sys-devel/gcc-config: 2.11::gentoo sys-devel/libtool: 2.4.7-r1::gentoo sys-devel/llvm: 15.0.7::gentoo, 16.0.3::gentoo sys-devel/make: 4.4.1::gentoo sys-kernel/linux-headers: 6.3::gentoo (virtual/os-headers) sys-libs/musl: 1.2.4::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 volatile: False sync-rsync-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-extra-opts: sync-rsync-verify-metamanifest: yes local location: /var/db/repos/local masters: gentoo volatile: False ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="*" CBUILD="x86_64-gentoo-linux-musl" CFLAGS="-O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches " CHOST="x86_64-gentoo-linux-musl" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -D_GLIBCXX_ASSERTIONS" DISTDIR="/var/cache/distfiles" EMERGE_DEFAULT_OPTS="--keep-going=y" 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 -march=native -fdiagnostics-color=always -frecord-gcc-switches " FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches " GENTOO_MIRRORS="http://mirror.bytemark.co.uk/gentoo/ http://www.mirrorservice.org/sites/distfiles.gentoo.org/ http://mirrors.soeasyto.com/distfiles.gentoo.org/" INSTALL_MASK="charset.alias /usr/share/locale/locale.alias" LANG="C.UTF8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" LEX="flex" 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" USE="acl amd64 bzip2 cet cli crypt dri fortran hardened iconv ipv6 libglvnd libtirpc ncurses nls nptl openmp openssl pam pcre pie readline seccomp split-usr ssl ssp system-bootstrap system-llvm test-rust unicode valgrind verify-sig xattr xtpax zlib" 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="mmx mmxext sse sse2" ELIBC="musl" 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" 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_10" PYTHON_TARGETS="python3_11 python3_10 python3_8 python3_9" RUBY_TARGETS="ruby30" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy 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, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SHELL, SIZE, STRINGS, STRIP, YACC, YFLAGS
I think we need to guard all the LFS functions with a glibc check in msan, starting at e.g. https://github.com/llvm/llvm-project/blob/ed90cf1873aa696f7c99ea2eafc540206c2391e1/compiler-rt/lib/msan/msan_interceptors.cpp#L847. I'll look at it later.
Created attachment 861837 [details, diff] 0001-msan-Don-t-intercept-LFS-prlimit64-getrlimi64-on-mus.patch I need to test this more before sending it upstream.
(In reply to Sam James from comment #2) > Created attachment 861837 [details, diff] [details, diff] > 0001-msan-Don-t-intercept-LFS-prlimit64-getrlimi64-on-mus.patch > > I need to test this more before sending it upstream. We could always add your patch conditionally musl-only ... It can't be far off the target since MaskRay approved it.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6aa6d6441b56e5053007153e39960e203f34130c commit 6aa6d6441b56e5053007153e39960e203f34130c Author: Andreas K. Hüttel <dilfridge@gentoo.org> AuthorDate: 2024-03-07 17:33:36 +0000 Commit: Andreas K. Hüttel <dilfridge@gentoo.org> CommitDate: 2024-03-07 17:34:25 +0000 profiles, musl: stable-use-mask sys-libs/compiler-rt-sanitizers[msan] Bug: https://bugs.gentoo.org/906603 Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> profiles/features/musl/package.use.stable.mask | 4 ++++ 1 file changed, 4 insertions(+)