[radeonsi] debug assert in shader compile thread
Description
This is a minor issue and I'm not sure it indicates an actual bug in release builds, but when running with mesa built in debug I get this assert:
program: ../src/util/simple_mtx.h:89: simple_mtx_lock: Assertion `c != _SIMPLE_MTX_INVALID_VALUE' failed.
Aborted (core dumped)
Repro steps
- Build this attached a program: thread_compile.cpp
- Build mesa in debug.
- Run the program, you will most likely hit the above assert.
The program itself kicks off a compute shader compile and link and then destroys the GL context and shuts down immediately after.
The callstack on the shader compile thread is:
#1 0x00007ffff79e7859 in __GI_abort () at abort.c:79
#2 0x00007ffff79e7729 in __assert_fail_base (fmt=0x7ffff7b7d588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=0x7ffff5257690 "c != _SIMPLE_MTX_INVALID_VALUE", file=0x7ffff5257660 "../src/util/simple_mtx.h", line=89,
function=<optimized out>) at assert.c:92
#3 0x00007ffff79f8f36 in __GI___assert_fail (assertion=0x7ffff5257690 "c != _SIMPLE_MTX_INVALID_VALUE",
file=0x7ffff5257660 "../src/util/simple_mtx.h", line=89, function=0x7ffff5257ae0 <__PRETTY_FUNCTION__.31426> "simple_mtx_lock")
at assert.c:101
#4 0x00007ffff46ba2ad in simple_mtx_lock (mtx=0x5555557844dc) at ../src/util/simple_mtx.h:89
#5 0x00007ffff46bb569 in _mesa_lock_debug_state (ctx=0x555555749d00) at ../src/mesa/main/debug_output.c:693
#6 0x00007ffff46bba2c in _mesa_log_msg (ctx=0x555555749d00, source=MESA_DEBUG_SOURCE_SHADER_COMPILER, type=MESA_DEBUG_TYPE_OTHER, id=1,
severity=MESA_DEBUG_SEVERITY_NOTIFICATION, len=129,
buf=0x7fffafffd960 "Shader Stats: SGPRS: 24 VGPRS: 4 Code Size: 152 LDS: 0 Scratch: 0 Max Waves: 8 Spilled SGPRs: 0 Spilled VGPRs: 0 PrivMem VGPRs: 0") at ../src/mesa/main/debug_output.c:871
#7 0x00007ffff4766c14 in _mesa_gl_vdebugf (ctx=0x555555749d00, id=0x7ffff5858a6c <id>, source=MESA_DEBUG_SOURCE_SHADER_COMPILER,
type=MESA_DEBUG_TYPE_OTHER, severity=MESA_DEBUG_SEVERITY_NOTIFICATION,
fmtString=0x7ffff53ac210 "Shader Stats: SGPRS: %d VGPRS: %d Code Size: %d LDS: %d Scratch: %d Max Waves: %d Spilled SGPRs: %d Spilled VGPRs: %d PrivMem VGPRs: %d", args=0x7fffafffea10) at ../src/mesa/main/errors.c:238
#8 0x00007ffff45cf761 in st_debug_message (data=0x5555555c73b0, id=0x7ffff5858a6c <id>, ptype=PIPE_DEBUG_TYPE_SHADER_INFO,
fmt=0x7ffff53ac210 "Shader Stats: SGPRS: %d VGPRS: %d Code Size: %d LDS: %d Scratch: %d Max Waves: %d Spilled SGPRs: %d Spilled VGPRs: %d PrivMem VGPRs: %d", args=0x7fffafffea10) at ../src/mesa/state_tracker/st_debug.c:129
#9 0x00007ffff4b6ec66 in _pipe_debug_message (cb=0x555555cc6880, id=0x7ffff5858a6c <id>, type=PIPE_DEBUG_TYPE_SHADER_INFO,
fmt=0x7ffff53ac210 "Shader Stats: SGPRS: %d VGPRS: %d Code Size: %d LDS: %d Scratch: %d Max Waves: %d Spilled SGPRs: %d Spilled VGPRs: %d PrivMem VGPRs: %d") at ../src/util/u_debug.c:77
#10 0x00007ffff5009c7c in si_shader_dump_stats_for_shader_db (screen=0x5555556351c0, shader=0x555555cc6e40, debug=0x555555cc6880)
at ../src/gallium/drivers/radeonsi/si_shader.c:1035
#11 0x00007ffff500ce16 in si_compile_shader (sscreen=0x5555556351c0, compiler=0x555555635bf8, shader=0x555555cc6e40, debug=0x555555cc6880)
at ../src/gallium/drivers/radeonsi/si_shader.c:1919
#12 0x00007ffff500e519 in si_create_shader_variant (sscreen=0x5555556351c0, compiler=0x555555635bf8, shader=0x555555cc6e40,
debug=0x555555cc6880) at ../src/gallium/drivers/radeonsi/si_shader.c:2406
#13 0x00007ffff50c6bc8 in si_create_compute_state_async (job=0x555555cc6850, thread_index=9)
at ../src/gallium/drivers/radeonsi/si_compute.c:193
#14 0x00007ffff4b6da92 in util_queue_thread_func (input=0x55555563a4f0) at ../src/util/u_queue.c:308
#15 0x00007ffff4b6cb99 in impl_thrd_routine (p=0x55555563a510) at ../include/c11/threads_posix.h:87
#16 0x00007ffff750f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007ffff7ae4103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
and the callstack on the main thread that's calling GL is:
(gdb) bt
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007ffff4b6ca36 in sys_futex (addr1=0x555555cc6870, op=9, val1=2, timeout=0x0, addr2=0x0, val3=-1) at ../src/util/futex.h:39
#2 0x00007ffff4b6caa9 in futex_wait (addr=0x555555cc6870, value=2, timeout=0x0) at ../src/util/futex.h:51
#3 0x00007ffff4b6d5cc in do_futex_fence_wait (fence=0x555555cc6870, timeout=false, abs_timeout=0) at ../src/util/u_queue.c:127
#4 0x00007ffff4b6d63e in _util_queue_fence_wait (fence=0x555555cc6870) at ../src/util/u_queue.c:142
#5 0x00007ffff4b6d33f in util_queue_fence_wait (fence=0x555555cc6870) at ../src/util/u_queue.h:161
#6 0x00007ffff4b6e7a6 in util_queue_drop_job (queue=0x5555556358b0, fence=0x555555cc6870) at ../src/util/u_queue.c:641
#7 0x00007ffff50c8dbf in si_destroy_compute (program=0x555555cc6850) at ../src/gallium/drivers/radeonsi/si_compute.c:912
#8 0x00007ffff50c5f2b in si_compute_reference (dst=0x7fffffffe1a8, src=0x0) at ../src/gallium/drivers/radeonsi/si_compute.h:52
#9 0x00007ffff50c8ee5 in si_delete_compute_state (ctx=0x5555555eb3a0, state=0x555555cc6850)
at ../src/gallium/drivers/radeonsi/si_compute.c:939
#10 0x00007ffff51dcff7 in tc_call_delete_compute_state (pipe=0x5555555eb3a0, payload=0x55555572bbe8)
at ../src/gallium/auxiliary/util/u_threaded_context.c:536
#11 0x00007ffff51db9f7 in tc_batch_execute (job=0x55555572bbb0, thread_index=0) at ../src/gallium/auxiliary/util/u_threaded_context.c:96
#12 0x00007ffff51dbe39 in _tc_sync (tc=0x55555572b620, info=0x7ffff550d579 "", func=0x7ffff550db78 <__func__.15058> "tc_destroy")
at ../src/gallium/auxiliary/util/u_threaded_context.c:209
#13 0x00007ffff51e1e27 in tc_destroy (_pipe=0x55555572b620) at ../src/gallium/auxiliary/util/u_threaded_context.c:2576
#14 0x00007ffff45f3381 in st_destroy_context_priv (st=0x5555555c73b0, destroy_pipe=true) at ../src/mesa/state_tracker/st_context.c:471
#15 0x00007ffff45f4fbb in st_destroy_context (st=0x5555555c73b0) at ../src/mesa/state_tracker/st_context.c:1110
#16 0x00007ffff45d34cf in st_context_destroy (stctxi=0x5555555c73b0) at ../src/mesa/state_tracker/st_manager.c:814
#17 0x00007ffff45c227c in dri_destroy_context (cPriv=0x555555669ca0) at ../src/gallium/frontends/dri/dri_context.c:247
#18 0x00007ffff4df4f65 in driDestroyContext (pcp=0x555555669ca0) at ../src/mesa/drivers/dri/common/dri_util.c:528
#19 0x00007ffff7e19cc8 in dri3_destroy_context (context=0x55555566b750) at ../src/glx/dri3_glx.c:181
#20 0x00007ffff7df9998 in glXDestroyContext (dpy=0x5555555702e0, ctx=0x55555566b750) at ../src/glx/glxcmds.c:511
#21 0x00007ffff7f2a331 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#22 0x0000555555557225 in main ()
System information
System: Host: lupino Kernel: 5.4.0-40-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: Fluxbox 1.3.5 dm: GDM3
Distro: Ubuntu 20.04 LTS (Focal Fossa)
CPU: Topology: 8-Core model: AMD Ryzen 7 1700X bits: 64 type: MT MCP arch: Zen rev: 1 L2 cache: 4096 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 108800
Speed: 1889 MHz min/max: 2200/3400 MHz Core speeds (MHz): 1: 1886 2: 1889 3: 1885 4: 1887 5: 1889 6: 1887 7: 1888
8: 1887 9: 1887 10: 1894 11: 1886 12: 1884 13: 1993 14: 1886 15: 1886 16: 1888
Graphics: Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590]
vendor: PC Partner Limited driver: amdgpu v: kernel bus ID: 24:00.0 chip ID: 1002:67df
Device-2: NVIDIA TU102 [GeForce RTX 2080 Ti Rev. A] driver: N/A bus ID: 25:00.0 chip ID: 10de:1e07
Display: x11 server: X.Org 1.20.8 driver: ati,modesetting unloaded: fbdev,radeon,vesa resolution: 1920x1080~60Hz
OpenGL: renderer: AMD Radeon RX 480 Graphics (POLARIS10 DRM 3.35.0 5.4.0-40-generic LLVM 10.0.0)
v: 4.6 Mesa 20.2.0-devel (git-3c5512ce50) direct render: Yes