SIGFPE in Vulkan Validation Layer tests (AMD)
Description
Assuming a maxComputeSharedMemory
of 65536, the following shader causes a divide by 0 inside the shader compiler as the num_waves is calculated to be 0 on my machine.
#version 450
#extension GL_EXT_shared_memory_block : enable
// will be over the max if the spec constant uses default value
layout(constant_id = 0) const uint value = 4112;
// Both structs by themselves are 16 bytes less than the max
shared X {
vec4 x1[value];
vec4 x2;
};
shared Y {
int y1[16380];
int y2;
};
void main() {
x2.x = 0.0f; // prevent dead-code elimination
y2 = 0;
}
Log files (for system lockups / game freezes / crashes)
#1 aco::update_vgpr_sgpr_demand (program=program@entry=0x555558a04770, new_demand=..., new_demand@entry=...)
at ../src/amd/compiler/aco_live_var_analysis.cpp:445
#2 0x00007ffff61aff23 in aco::live_var_analysis (program=0x555558a04770) at ../src/amd/compiler/aco_live_var_analysis.cpp:487
#3 0x00007ffff617b9c2 in aco_postprocess_shader (options=options@entry=0x7fffffffa990, info=info@entry=0x7fffffffa9c0,
program=std::unique_ptr<aco::Program> = {...}) at /usr/include/c++/12/bits/unique_ptr.h:191
#4 0x00007ffff617c355 in aco_compile_shader (options=options@entry=0x7fffffffa990, info=info@entry=0x7fffffffa9c0, shader_count=shader_count@entry=1,
shaders=shaders@entry=0x7fffffffaf48, args=args@entry=0x7fffffffb2d0, build_binary=build_binary@entry=0x7ffff5f43ce0 <radv_aco_build_shader_binary>,
binary=0x7fffffffa978) at ../src/amd/compiler/aco_interface.cpp:235
#5 0x00007ffff5f45157 in shader_compile (device=device@entry=0x555559759880, shaders=shaders@entry=0x7fffffffaf48, shader_count=shader_count@entry=1,
info=info@entry=0x7fffffffaf58, args=args@entry=0x7fffffffb2d0, options=options@entry=0x7fffffffab50, stage=<optimized out>)
at ../src/amd/vulkan/radv_shader.c:2217
#6 0x00007ffff5f49509 in radv_shader_nir_to_asm (device=device@entry=0x555559759880, cache=cache@entry=0x55555980f520, pl_stage=pl_stage@entry=0x7fffffffaf00,
shaders=shaders@entry=0x7fffffffaf48, shader_count=shader_count@entry=1, key=key@entry=0x7fffffffc900, keep_shader_info=false, keep_statistic_info=false,
binary_out=0x7fffffffaeb8) at ../src/amd/vulkan/radv_shader.c:2245
#7 0x00007ffff5f1c477 in radv_compute_pipeline_compile (pipeline=pipeline@entry=0x55555979dde0, pipeline_layout=pipeline_layout@entry=0x555559868360,
device=device@entry=0x555559759880, cache=cache@entry=0x55555980f520, pipeline_key=pipeline_key@entry=0x7fffffffc900, pStage=pStage@entry=0x5555597a4fc0,
flags=0, creation_feedback=0x0) at ../src/amd/vulkan/radv_pipeline_compute.c:228
#8 0x00007ffff5f1c9bd in radv_compute_pipeline_create (_device=_device@entry=0x555559759880, _cache=_cache@entry=0x55555980f520,
pCreateInfo=pCreateInfo@entry=0x5555597a4fa8, pAllocator=pAllocator@entry=0x0, pPipeline=pPipeline@entry=0x7fffffffd5a8)
at ../src/amd/vulkan/radv_pipeline_compute.c:295
#9 0x00007ffff5f1cb46 in radv_create_compute_pipelines (pPipelines=0x7fffffffd5a8, pAllocator=0x0, pCreateInfos=<optimized out>, count=1,
pipelineCache=0x55555980f520, _device=0x555559759880) at ../src/amd/vulkan/radv_pipeline_compute.c:321
#10 radv_CreateComputePipelines (_device=0x555559759880, pipelineCache=0x55555980f520, count=1, pCreateInfos=<optimized out>, pAllocator=0x0,
pPipelines=0x7fffffffd5a8) at ../src/amd/vulkan/radv_pipeline_compute.c:350
#11 0x00007fffe78863d0 in DispatchCreateComputePipelines (device=0x555559759880, pipelineCache=0x55555980f520, createInfoCount=1, pCreateInfos=0x7fffffffd520,
pAllocator=0x0, pPipelines=0x7fffffffd5a8) at /home/gwebb/src/Vulkan-ValidationLayers/layers/layer_chassis_dispatch_manual.cpp:1552
#12 0x00007fffe7466c70 in vulkan_layer_chassis::CreateComputePipelines (device=0x555559759880, pipelineCache=0xee647e0000000009, createInfoCount=1,
pCreateInfos=0x7fffffffd520, pAllocator=0x0, pPipelines=0x7fffffffd5a8) at /home/gwebb/src/Vulkan-ValidationLayers/layers/vulkan/generated/chassis.cpp:666
#13 0x0000555555a4dfb1 in CreateComputePipelineHelper::CreateComputePipeline (this=0x7fffffffd4c0, implicit_destroy=true, do_late_bind=true)
at /home/gwebb/src/Vulkan-ValidationLayers/tests/framework/layer_validation_tests.cpp:1664
#14 0x00005555563e9870 in PositiveShaderLimits_ComputeSharedMemoryWorkgroupMemoryExplicitLayoutSpec_Test::TestBody (this=0x5555589ca7e0)
at /home/gwebb/src/Vulkan-ValidationLayers/tests/unit/shader_limits_positive.cpp:151
Steps to reproduce
git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git
cd Vulkan-ValidationLayers
cmake -S . -B build -D UPDATE_DEPS=ON -D BUILD_WERROR=ON -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug
cd build
EXPORT VK_LAYER_PATH=$(pwd)/layers
./tests/vk_layer_validation_tests --gtest_filter=PositiveShaderLimits.ComputeSharedMemoryWorkgroupMemoryExplicitLayoutSpec
System information
System:
Host: mateus Kernel: 6.2.0-1011-lowlatency arch: x86_64 bits: 64
compiler: N/A Desktop: GNOME v: 44.3 tk: GTK v: 3.24.37 wm: gnome-shell
dm: GDM3 Distro: Ubuntu 23.04 (Lunar Lobster)
CPU:
Info: 8-core model: AMD Ryzen 7 5800U with Radeon Graphics bits: 64
type: MT MCP arch: Zen 3 rev: 0 cache: L1: 512 KiB L2: 4 MiB L3: 16 MiB
Speed (MHz): avg: 1623 high: 1900 min/max: 1600/4505 boost: enabled cores:
1: 1600 2: 1600 3: 1600 4: 1600 5: 1600 6: 1600 7: 1600 8: 1600 9: 1373
10: 1600 11: 1600 12: 1900 13: 1900 14: 1600 15: 1600 16: 1600
bogomips: 60687
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
Device-1: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
vendor: Hewlett-Packard driver: amdgpu v: kernel arch: GCN-5 pcie:
speed: 8 GT/s lanes: 16 ports: active: eDP-1 empty: DP-1,HDMI-A-1
bus-ID: 03:00.0 chip-ID: 1002:1638 temp: 48.0 C
Device-2: Chicony HP Wide Vision HD Camera type: USB driver: uvcvideo
bus-ID: 1-3:2 chip-ID: 04f2:b735
Display: wayland server: X.org v: 1.21.1.7 with: Xwayland v: 22.1.8
compositor: gnome-shell driver: gpu: amdgpu display-ID: 0
Monitor-1: eDP-1 model: AU Optronics 0x4195 res: 2560x1600 dpi: 227
diag: 337mm (13.3")
API: OpenGL v: 4.6 Mesa 23.1.6 - kisak-mesa PPA renderer: AMD Radeon
Graphics (renoir LLVM 15.0.7 DRM 3.49 6.2.0-1011-lowlatency)
direct-render: Yes
Regression
Unknown
API captures (if applicable, optional)
Can provide if needed.
Further information (optional)
Different but related error with RADV_DEBUG=llvm:
ac_rtld error(2): too much LDS (used = 65808, max = 65536)
Segmentation fault (core dumped)
Edited by Gareth Webb