Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 884231 - sys-devel/llvm-15.0.5: heap corruption inside media-libs/mesa if llvm built with LTO: free(): invalid pointer
Summary: sys-devel/llvm-15.0.5: heap corruption inside media-libs/mesa if llvm built w...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-12-04 03:17 UTC by WGH
Modified: 2024-03-06 06:10 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description WGH 2022-12-04 03:17:40 UTC
Almost every graphical application (e.g. xterm) crashes immediately on start if LLVM is compiled with LTO enabled. The crash is related to Mesa (see stack trace below).

Reproducible: Always

Steps to Reproduce:
1. emerge llvm with LTO
2. have amdgpu (maybe optional)
3. try to run X11 program like xterm



I've been using Mesa itself with LTO for some time with no problems. I've only tried LTO with LLVM just now.

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f5a609b300f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f5a60965b62 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f5a60950471 in __GI_abort () at abort.c:79
#4  0x00007f5a609a6f89 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f5a60abf31e "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#5  0x00007f5a609bd0fa in malloc_printerr (str=str@entry=0x7f5a60abcf5c "free(): invalid pointer") at malloc.c:5660
#6  0x00007f5a609bec6c in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:4435
#7  0x00007f5a609c18cf in __GI___libc_free (mem=<optimized out>) at malloc.c:3385
#8  0x00007f5a464022b0 in LLVMAddIncoming () from /usr/lib/llvm/15/lib64/libLLVM-15.so
#9  0x00007f5a52e2326b in visit_post_phi (instr=<optimized out>, instr=<optimized out>, llvm_phi=0x7f5a3c088a58, ctx=0x7f5a511f9450)
    at ../mesa-22.2.3/src/amd/llvm/ac_nir_to_llvm.c:5027
#10 phi_post_pass (ctx=0x7f5a511f9450) at ../mesa-22.2.3/src/amd/llvm/ac_nir_to_llvm.c:5035
#11 ac_nir_translate (ac=<optimized out>, abi=<optimized out>, args=<optimized out>, nir=0x55d732777fd0) at ../mesa-22.2.3/src/amd/llvm/ac_nir_to_llvm.c:5520
#12 0x00007f5a52d4d950 in si_llvm_translate_nir (ctx=ctx@entry=0x7f5a511fa2e0, shader=shader@entry=0x7f5a3c013360, nir=0x55d732777fd0, free_nir=<optimized out>,
    ngg_cull_shader=ngg_cull_shader@entry=false) at ../mesa-22.2.3/src/gallium/drivers/radeonsi/si_shader_llvm.c:1072
#13 0x00007f5a52d5030e in si_llvm_compile_shader (sscreen=0x55d7328c0970, compiler=0x55d7328c14b0, shader=0x7f5a3c013360, so=<optimized out>, debug=0x55d7331067f0,
    nir=0x55d732777fd0, free_nir=<optimized out>) at ../mesa-22.2.3/src/gallium/drivers/radeonsi/si_shader_llvm.c:1160
#14 0x00007f5a52d3b23a in si_compile_shader (sscreen=0x55d7328c0970, compiler=0x55d7328c14b0, shader=0x7f5a3c013360, debug=0x55d7331067f0)
    at ../mesa-22.2.3/src/gallium/drivers/radeonsi/si_shader.c:1873
#15 0x00007f5a52d7273b in si_init_shader_selector_async (job=0x55d7331067c0, gdata=<optimized out>, thread_index=<optimized out>)
    at ../mesa-22.2.3/src/gallium/drivers/radeonsi/si_state_shaders.cpp:3033
#16 0x00007f5a5268f905 in util_queue_thread_func (input=input@entry=0x55d73292f3f0) at ../mesa-22.2.3/src/util/u_queue.c:306
#17 0x00007f5a526c93c7 in impl_thrd_routine (p=<optimized out>) at ../mesa-22.2.3/src/c11/impl/threads_posix.c:67
#18 0x00007f5a609b136a in start_thread (arg=<optimized out>) at pthread_create.c:442
#19 0x00007f5a60a323bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb)

Portage 3.0.38.1 (python 3.10.8-final-0, default/linux/amd64/17.1/systemd, gcc-11.3.0, glibc-2.36-r5, 6.0.9-gentoo x86_64)
=================================================================
System uname: Linux-6.0.9-gentoo-x86_64-AMD_Ryzen_5_PRO_4650U_with_Radeon_Graphics-with-glibc2.36
KiB Mem:    65198072 total,  22061076 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Sat, 03 Dec 2022 16:15:01 +0000
Head commit of repository gentoo: 7154811d34a5a48f7b5c14471249b7dc74617fdb
Timestamp of repository brother-overlay: Fri, 02 Dec 2022 20:02:02 +0000
Head commit of repository brother-overlay: c8a870ced58027f42d558b352bd1580c50f39643

Timestamp of repository qownnotes-overlay: Sat, 03 Dec 2022 14:31:44 +0000
Head commit of repository qownnotes-overlay: ce55f5c571e080c9faa9e430ae0ff4fdf0d8cd15

sh bash 5.1_p16-r2
ld GNU ld (Gentoo 2.38 p4) 2.38
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.34.1-r4::gentoo
dev-lang/python:           3.10.8_p3::gentoo, 3.11.0_p2::gentoo
dev-lang/rust:             1.65.0::gentoo
dev-util/cmake:            3.24.3::gentoo
dev-util/meson:            0.63.3::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-apps/systemd:          251.7::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.38-r2::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/clang:           14.0.6-r1::gentoo, 15.0.5::gentoo
sys-devel/gcc:             11.3.0::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/lld:             15.0.5::gentoo
sys-devel/llvm:            14.0.6-r2::gentoo, 15.0.5::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  6.0::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.europe.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts:

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

local
    location: /var/db/repos/local
    masters: gentoo

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

Installed sets: @pylsp
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.8/conf"
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.1/ext-active/ /etc/php/cgi-php8.1/ext-active/ /etc/php/cli-php8.1/ext-active/ /etc/php/fpm-php8.1/ext-active/ /etc/php/phpdbg-php8.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY 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"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live 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 strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j10"
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"
SHELL="/bin/zsh"
USE="acl amd64 bzip2 cli crypt dri fortran gdbm iconv ipv6 libglvnd libtirpc multilib ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl systemd test-rust udev unicode xattr 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 aes avx avx2 f16c fma3 pclmul popcnt rdrand sha 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" GRUB_PLATFORMS="efi-64" 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_10" RUBY_TARGETS="ruby27" 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, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, 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

sys-devel/llvm-15.0.5::gentoo was built with the following:
USE="binutils-plugin libffi ncurses -debug -doc -exegesis -libedit -test -verify-sig -xar -xml -z3 -zstd" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="(AArch64) (AMDGPU) (ARM) (AVR) (BPF) (Hexagon) (Lanai) (MSP430) (Mips) (NVPTX) (PowerPC) (RISCV) (Sparc) (SystemZ) (VE) (WebAssembly) (X86) (XCore) (-ARC) (-CSKY) (-DirectX) (-LoongArch) (-M68k) (-SPIRV)"
CFLAGS="-O2 -pipe -march=native -flto=10 -fno-fat-lto-objects"
CXXFLAGS="-O2 -pipe -march=native -flto=10 -fno-fat-lto-objects"
FEATURES="multilib-strict fixlafiles assume-digests ipc-sandbox buildpkg-live qa-unresolved-soname-deps config-protect-if-modified ebuild-locks usersync xattr news binpkg-logs binpkg-docompress unmerge-logs preserve-libs usersandbox network-sandbox merge-sync strict unmerge-orphans distlocks parallel-fetch binpkg-dostrip userfetch protect-owned unknown-features-warn sandbox userpriv sfperms pid-sandbox"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -flto=10 -fuse-linker-plugin"


media-libs/mesa-22.2.3::gentoo was built with the following:
USE="X debug gles2 llvm proprietary-codecs vaapi vdpau vulkan zstd -d3d9 -gles1 -lm-sensors -opencl -osmesa (-selinux) -test -unwind -valgrind -vulkan-overlay -wayland -xa -xvmc -zink" ABI_X86="32 (64) (-x32)" CPU_FLAGS_X86="sse2" VIDEO_CARDS="radeonsi -d3d12 (-freedreno) -intel (-lima) -nouveau (-panfrost) -r300 -r600 -radeon (-v3d) (-vc4) -virgl (-vivante) -vmware"
CFLAGS="-O2 -pipe -march=native -flto=10 -fno-fat-lto-objects -ggdb -flto=10 -fno-fat-lto-objects"
CXXFLAGS="-O2 -pipe -march=native -flto=10 -fno-fat-lto-objects -ggdb -flto=10 -fno-fat-lto-objects"
FEATURES="news userfetch network-sandbox strict usersync binpkg-docompress preserve-libs unmerge-logs buildpkg-live parallel-fetch xattr compressdebug sandbox usersandbox merge-sync assume-digests pid-sandbox sfperms distlocks splitdebug unmerge-orphans unknown-features-warn config-protect-if-modified binpkg-logs qa-unresolved-soname-deps ebuild-locks protect-owned multilib-strict binpkg-dostrip fixlafiles ipc-sandbox userpriv"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -flto=10 -fuse-linker-plugin -flto=10 -fuse-linker-plugin"
Comment 1 Matt Turner gentoo-dev 2023-09-29 02:27:53 UTC
This looks like the same bug as https://bugs.gentoo.org/835394 (">media-libs/mesa-21.1.7 AMDGPU free() invalid pointer").
Comment 2 Holger Hoffstätte 2023-12-15 09:49:19 UTC
see also: https://bugs.gentoo.org/873670
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-06 06:10:47 UTC
I suspect this was fixed by the changes in bug 873670.