thedarkmodvr never finishes linking shaders
Vega 64, mesa git and mesa 20.1.3.
When starting thedarkmodvr (commit c572322a85943aacd1aaa8bd723526db3f1b576c), compiling shaders never finishes, mesa uses 100% cpu and slowly eats memory until eventually it is killed by the oom killer.
No VR hardware is required to reproduce, it happens before it initializes any VR support.
To reproduce, get the darkmod first: https://www.thedarkmod.com/downloads/
- Place downloader in
darkmod/tdm_update.linux64
and run from darkmod/ as working directory. -
git clone https://github.com/fholger/thedarkmodvr.git
next to the darkmod/ directory cd thedarkmodvr; cmake -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild; ninja -C build
the build system will place ./thedarkmodvr.x64
in the darkmod/ directory if it is found next to the thedarkmodvr/ directory. Running ./thedarkmodvr.x64 in the darkmod/ directory prints a bunch of warnings about missing shaders which are not related. After printing Linking GLSL program depth ...
it should hang with a black window, 100% CPU usage and slowly eat all your ram.
The shaders it tries to link are here: https://github.com/fholger/thedarkmodvr/tree/c572322a85943aacd1aaa8bd723526db3f1b576c/glprogs/stages/depth
the other two subdirectories in glprogs/stages/ also cause the issue. Removing/renaming the glprogs/stages/ subdirectory lets the game start up to the menu.
apitrace trace and glretrace do not reproduce the issue.
Running in gdb and interrupting shows this trace
Thread 1 "thedarkmodvr.x6" received signal SIGINT, Interrupt.
0x00007fffddeb446c in program_resource_visitor::recursion (this=0x7fffffffb990, t=0x5c98630, name=0x7fffffffb900, name_length=15, row_major=false, record_type=0x5c98630, packing=GLSL_INTERFACE_PACKING_STD140, last_field=false, record_array_count=12201610, named_ifc_member=0x0) at ../src/compiler/glsl/link_uniforms.cpp:365
365 ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field);
(gdb) bt
#0 0x00007fffddeb446c in program_resource_visitor::recursion (this=0x7fffffffb990, t=0x5c98630, name=0x7fffffffb900, name_length=15, row_major=false, record_type=0x5c98630, packing=GLSL_INTERFACE_PACKING_STD140, last_field=false, record_array_count=12201610, named_ifc_member=0x0) at ../src/compiler/glsl/link_uniforms.cpp:365
#1 0x00007fffddeb46ee in program_resource_visitor::recursion (this=0x7fffffffb990, t=0x5c80d10, name=0x7fffffffb900, name_length=6, row_major=false, record_type=0x0, packing=GLSL_INTERFACE_PACKING_STD140, last_field=true, record_array_count=12201610, named_ifc_member=0x0) at ../src/compiler/glsl/link_uniforms.cpp:421
#2 0x00007fffddeb4533 in program_resource_visitor::recursion (this=0x7fffffffb990, t=0x5c81250, name=0x7fffffffb900, name_length=0, row_major=false, record_type=0x0, packing=GLSL_INTERFACE_PACKING_STD140, last_field=false, record_array_count=1, named_ifc_member=0x0) at ../src/compiler/glsl/link_uniforms.cpp:383
#3 0x00007fffddeb3efe in program_resource_visitor::process (this=0x7fffffffb990, type=0x5c81250, name=0x7fffde51f527 "", use_std430_as_default=true) at ../src/compiler/glsl/link_uniforms.cpp:273
#4 0x00007fffddeba949 in link_uniform_blocks (mem_ctx=0x5d49140, ctx=0x55af930, prog=0x5d4dc90, shader=0x5cd4c90, ubo_blocks=0x7fffffffba98, num_ubo_blocks=0x7fffffffba64, ssbo_blocks=0x7fffffffbaa0, num_ssbo_blocks=0x7fffffffba68) at ../src/compiler/glsl/link_uniform_blocks.cpp:447
#5 0x00007fffddea878b in link_intrastage_shaders (mem_ctx=0x5d49140, ctx=0x55af930, prog=0x5d4dc90, shader_list=0x5d43150, num_shaders=1, allow_missing_main=false) at ../src/compiler/glsl/linker.cpp:2540
#6 0x00007fffddeadf10 in link_shaders (ctx=0x55af930, prog=0x5d4dc90) at ../src/compiler/glsl/linker.cpp:4703
#7 0x00007fffdda6c3a5 in _mesa_glsl_link_shader (ctx=0x55af930, prog=0x5d4dc90) at ../src/mesa/program/ir_to_mesa.cpp:3099
#8 0x00007fffddc2c761 in link_program (no_error=false, shProg=0x5d4dc90, ctx=0x55af930) at ../src/mesa/main/shaderapi.c:1311
#9 link_program_error (ctx=0x55af930, shProg=0x5d4dc90) at ../src/mesa/main/shaderapi.c:1419
#10 0x00007fffddc2dff7 in _mesa_LinkProgram (programObj=73) at ../src/mesa/main/shaderapi.c:1911
#11 0x000000000076233d in GLSLProgram::Link (this=0x5c78bf0) at ../renderer/GLSLProgram.cpp:83
#12 0x000000000076282e in GLSLProgram::InitFromFiles (this=0x5c78bf0, vertexFile=0x12f4a46 "stages/depth/depth.vert.glsl", fragmentFile=0x12f4a29 "stages/depth/depth.frag.glsl", defines=...) at ../renderer/GLSLProgram.cpp:150
#13 0x0000000000c0cc6f in (anonymous namespace)::LoadShader (shader=0x5c78bf0, maxSupportedDrawsPerBatch=12201610, bindless=false) at ../renderer/backend/DepthStage.cpp:42
#14 0x0000000000c0cf61 in operator() (__closure=0x7fffffffc150, program=0x5c78bf0) at ../renderer/backend/DepthStage.cpp:86
#15 0x0000000000c0eb18 in std::__invoke_impl<void, DepthStage::Init()::<lambda(GLSLProgram*)>&, GLSLProgram*>(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/10.1.0/bits/invoke.h:60
#16 0x0000000000c0e889 in std::__invoke_r<void, DepthStage::Init()::<lambda(GLSLProgram*)>&, GLSLProgram*>(struct {...} &) (__fn=...) at /usr/include/c++/10.1.0/bits/invoke.h:153
#17 0x0000000000c0e65a in std::_Function_handler<void(GLSLProgram*), DepthStage::Init()::<lambda(GLSLProgram*)> >::_M_invoke(const std::_Any_data &, GLSLProgram *&&) (__functor=..., __args#0=@0x7fffffffbfd0: 0x5c78bf0) at /usr/include/c++/10.1.0/bits/std_function.h:291
#18 0x000000000076da53 in std::function<void (GLSLProgram*)>::operator()(GLSLProgram*) const (this=0x7fffffffc150, __args#0=0x5c78bf0) at /usr/include/c++/10.1.0/bits/std_function.h:622
#19 0x00000000007692c2 in GLSLProgramManager::LoadFromGenerator(char const*, std::function<void (GLSLProgram*)> const&) (this=0x25deba0 <programManagerInstance>, name=0x12f4a85 "depth", generator=...) at ../renderer/GLSLProgramManager.cpp:127
#20 0x0000000000c0cffd in DepthStage::Init (this=0x28a3780 <renderBackendImpl+192>) at ../renderer/backend/DepthStage.cpp:86
#21 0x0000000000c16476 in RenderBackend::Init (this=0x28a36c0 <renderBackendImpl>) at ../renderer/backend/RenderBackend.cpp:52
#22 0x00000000007da8a6 in R_InitOpenGL () at ../renderer/RenderSystem_init.cpp:416
#23 0x00000000007e01e7 in idRenderSystemLocal::InitOpenGL (this=0x25e3400 <tr>) at ../renderer/RenderSystem_init.cpp:1952
#24 0x00000000004c0281 in idCommonLocal::InitRenderSystem (this=0x16bf8e0 <commonLocal>) at ../framework/Common.cpp:2460
#25 0x00000000004c1062 in idCommonLocal::InitGame (this=0x16bf8e0 <commonLocal>) at ../framework/Common.cpp:3063
#26 0x00000000004c0b2a in idCommonLocal::Init (this=0x16bf8e0 <commonLocal>, argc=0, argv=0x0, cmdline=0x0) at ../framework/Common.cpp:2869
#27 0x0000000000c8e44a in main (argc=1, argv=0x7fffffffd858) at ../sys/posix/platform_linux.cpp:567
Downstream issue: https://github.com/fholger/thedarkmodvr/issues/15#issuecomment-661032003