llvmpipe / softpipe: GPU Caps Viewer OpenGL 1.x and 2.x 3D demos from OpenGL demos group segfault with MinGW-w64 GCC debug optimized or release binaries
Crash occurs only with 3D demos from OpenGL demos group. There are some OpenGL 1.x and 2.x 3D demos in GeeXLab demos group, but those run normally. As I specified in title, crashes don't reproduce with MSVC binaries and also MinGW if disabling optimizations (builtype=debug) for some reason. Linking dependencies statically or dynamically or enabling / disabling futex or even disabling LLVM usage has no effect on this issue. Even at backtrace level there are no meaningful differences.
Most recent commit I tested this with
commit 19fc870ac65845daf3c6176ecb06786acaf829e6 (HEAD -> main, origin/main, origin/HEAD)
Author: Kenneth Graunke <kenneth@whitecape.org>
Date: Tue Sep 6 17:18:16 2022 -0700
intel/compiler: Use subgroup invocation for ICP handle loads
...
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18455>
Regression
Yes, this is a long standing regression from around 21.1 cycle or even way back to 19.3 cycle. I don't remember if it was reproducible with the old Scons build. I tried bisecting it when it was fresh but other issues being in the way, notably more broad crashes and build failures that were later resolved made bisecting to a range smaller than 150-200 commits impossible.
Build process
- Build was done in a MSYS2 MINGW32 shell
- Update and install dependencies
pacman -Syu
pacman -Syu;pacman -S flex,bison,mingw-w64-i686-{cc,gdb,llvm,meson,pkgconf,python-mako,vulkan-devel,zstd} --needed --noconfirm
- Build with swrast only
/mingw32/bin/meson setup build/gcc-x86 --libdir="lib/x86" --pkgconfig.relocatable -Dzstd=enabled --backend=ninja --buildtype=debugoptimized -Db_ndebug=false --force-fallback-for= -Dcpp_rtti=true -Dllvm=enabled -Dshared-llvm=enabled --cmake-prefix-path= -Dgallium-drivers=swrast -Dvulkan-drivers= -Dgallium-d3d10umd=false -Dspirv-to-dxil=false -Dshared-glapi=enabled -Dgles1=enabled -Dgles2=enabled -Degl=enabled -Dosmesa=false -Dbuild-tests=false -Dmicrosoft-clc=disabled -Dgallium-opencl=disabled -Dc_args="-march=core2 -pipe" -Dcpp_args="-march=core2 -pipe" -Ddraw-use-llvm=true -Dmin-windows-version=7
- Build with swrast, zink and d3d12
/mingw32/bin/meson setup build/gcc-x86 --libdir="lib/x86" --pkgconfig.relocatable -Dzstd=enabled --backend=ninja --buildtype=debugoptimized -Db_ndebug=true --force-fallback-for= -Dcpp_rtti=true -Dllvm=enabled -Dshared-llvm=enabled --cmake-prefix-path= -Dgallium-drivers=swrast,zink,d3d12 -Dvulkan-drivers= -Dgallium-d3d10umd=false -Dspirv-to-dxil=true -Dshared-glapi=enabled -Dgles1=enabled -Dgles2=enabled -Degl=enabled -Dosmesa=false -Dbuild-tests=false -Dmicrosoft-clc=disabled -Dgallium-opencl=disabled -Dc_args="-march=core2 -pipe" -Dcpp_args="-march=core2 -pipe" -Ddraw-use-llvm=true -Dmin-windows-version=7
Backtraces
- Build with swrast only
Thread 19 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1360.0x5ec]
0x6e8c05e8 in _mesa_Lightfv@12 (light=16384, pname=4611, params=0x7a9f824) at ../../src/mesa/main/light.c:284
284 TRANSFORM_POINT(temp, ctx->ModelviewMatrixStack.Top->m, params);
(gdb) bt
#0 0x6e8c05e8 in _mesa_Lightfv@12 (light=16384, pname=4611, params=0x7a9f824)
at ../../src/mesa/main/light.c:284
#1 0x74edbdb5 in core3d!?push@o3Stack@oZone3D_nsp@@QAEXPAX@Z ()
from C:\Software\systools\GPU\GPU_Caps_Viewer\core3d.dll
#2 0x00004000 in ?? ()
#3 0x00001203 in ?? ()
#4 0x07a9f824 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
- Build with swrast, zink and d3d12
Thread 20 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8972.0xbd4]
0x6d524e09 in _mesa_RasterPos (ctx=0x7526a70, vObj=0x737f830) at ../../src/mesa/main/rastpos.c:515
515 TRANSFORM_POINT(ctx->Current.RasterTexCoords[u],
(gdb) bt
#0 0x6d524e09 in _mesa_RasterPos (ctx=0x7526a70, vObj=0x737f830) at ../../src/mesa/main/rastpos.c:515
#1 0x6d9c6876 in st_RasterPos (ctx=<optimized out>, ctx@entry=0x7526a70, v=<optimized out>,
v@entry=0x737f830) at ../../src/mesa/state_tracker/st_cb_rasterpos.c:236
#2 0x6d935b57 in rasterpos (x=x@entry=0, y=y@entry=0, z=z@entry=0, w=w@entry=1)
at ../../src/mesa/main/rastpos.c:549
#3 0x6d525f3f in _mesa_RasterPos2f@8 (x=0, y=0) at ../../src/mesa/main/rastpos.c:562
#4 0x74e29e74 in core3d!?push@o3Stack@oZone3D_nsp@@QAEXPAX@Z ()
from C:\Software\systools\GPU\GPU_Caps_Viewer\core3d.dll
#5 0x00000000 in ?? ()
This backtrace is different than the one with swrast build only despite the fact that on my system swrast is default as there is no d3d12 or Vulkan hardware acceleration available.