nir: nir_opt_varyings uses more stack than musl libc has
System information
- OS: Gentoo Linux
- GPU: AMD Raphael 7945HX/Nvidia AD107M
- Kernel version: 6.8.4
- Mesa version: Mesa 24.1.0-devel (git-1f4662cc)
- Desktop manager and compositor: sway 1.9
Describe the issue
nir_opt_varyings alloc a big struct (struct linkage_info
) on stack. The size of linkage_info is too big (81200 bytes) for musl libc. The size of stack in musl libc is 132KB.
https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread-stack-size
* thread #14, name = 'alacritty:gl0', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0x7ffff5b52b38)
* frame #0: 0x00007ffff363967b radeonsi_dri.so`nir_opt_varyings(producer=0x00007fffe1d50cb0, consumer=0x00007fffe1d50eb0, spirv=false, max_uniform_components=16384, max_ubos_per_stage=15) at nir_opt_varyings.
c:4116
frame #1: 0x00007ffff35090f9 radeonsi_dri.so`gl_nir_lower_optimize_varyings(consts=0x00007fffea4a3d28, prog=0x00007ffff7011740, spirv=<unavailable>) at gl_nir_linker.c:1363:10
frame #2: 0x00007ffff3519f77 radeonsi_dri.so`gl_nir_link_varyings(consts=0x00007fffea4a3d28, exts=0x00007fffea4a5348, api=API_OPENGL_CORE, prog=0x00007ffff7011740) at gl_nir_link_varyings.c:4607:7
frame #3: 0x00007ffff350aab5 radeonsi_dri.so`gl_nir_link_glsl(consts=0x00007fffea4a3d28, exts=0x00007fffea4a5348, api=API_OPENGL_CORE, prog=0x00007ffff7011740) at gl_nir_linker.c:2125:9
frame #4: 0x00007ffff342037b radeonsi_dri.so`::st_link_shader(gl_context *, gl_shader_program *) [inlined] st_link_glsl_to_nir(ctx=0x00007fffea490080, shader_program=0x00007ffff7011740) at st_glsl_to_nir.cpp:571:12
frame #5: 0x00007ffff34200d9 radeonsi_dri.so`st_link_shader(ctx=0x00007fffea490080, prog=0x00007ffff7011740) at st_glsl_to_nir.cpp:983:35
frame #6: 0x00007ffff33739be radeonsi_dri.so`link_program_error [inlined] link_program(ctx=<unavailable>, shProg=0x00007ffff7011740, no_error=false) at shaderapi.c:1336:4
frame #7: 0x00007ffff33738fc radeonsi_dri.so`link_program_error(ctx=0x00007fffea490080, shProg=0x00007ffff7011740) at shaderapi.c:1445:4
frame #8: 0x00007ffff32b7baa radeonsi_dri.so`_mesa_unmarshal_LinkProgram(ctx=<unavailable>, cmd=<unavailable>) at marshal_generated2.c:1677:4
frame #9: 0x00007ffff31f2704 radeonsi_dri.so`glthread_unmarshal_batch(job=0x00007fffea4901f8, gdata=<unavailable>, thread_index=<unavailable>) at glthread.c:141:14
frame #10: 0x00007ffff31bda1e radeonsi_dri.so`util_queue_thread_func(input=0x00007ffff6e489b0) at u_queue.c:309:10
frame #11: 0x00007ffff31db666 radeonsi_dri.so`impl_thrd_routine(p=<unavailable>) at threads_posix.c:67:29
radeonsi_dri.so`nir_opt_varyings:
0x7ffff3639660 <+0>: pushq %rbp
0x7ffff3639661 <+1>: pushq %r15
0x7ffff3639663 <+3>: pushq %r14
0x7ffff3639665 <+5>: pushq %r13
0x7ffff3639667 <+7>: pushq %r12
0x7ffff3639669 <+9>: pushq %rbx
0x7ffff363966a <+10>: movq %rsp, %r11
0x7ffff363966d <+13>: subq $0x25000, %r11 ; imm = 0x25000
0x7ffff3639674 <+20>: subq $0x1000, %rsp ; imm = 0x1000
-> 0x7ffff363967b <+27>: movq $0x0, (%rsp)
0x7ffff3639683 <+35>: cmpq %r11, %rsp
0x7ffff3639686 <+38>: jne 0x7ffff3639674 ; <+20> at nir_opt_varyings.c:4116
0x7ffff3639688 <+40>: subq $0x618, %rsp ; imm = 0x618
0x7ffff363968f <+47>: movl %edx, %ebx
0x7ffff3639691 <+49>: movq %fs:0x28, %rax
0x7ffff363969a <+58>: movq %rax, 0x25610(%rsp)
0x7ffff36396a2 <+66>: cmpb $0x4, 0x55(%rsi)
...
(lldb) register read rsp
rsp = 0x00007ffff5b52b38
(lldb) memory region 0x00007ffff5b52b38
[0x00007ffff5b51000-0x00007ffff5b53000) ---
(lldb) memory region 0x00007ffff5b54000
[0x00007ffff5b53000-0x00007ffff5b74000) rw-
Regression
It's a regression of !26819 (merged)