sysgpu: Index OOB in shader compiler #1343
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach#1343
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Note: 2863311530 is 0xAAAAAAAA, so it seems like the index is
undefined.I'd love to add a MRE, but I've no idea what might cause this and the shader is quite big. I'll attach it below in the hope that it helps.
ppu.wgsl
Tried getting a bit more info on what's going wrong. I've added some more detail as to how I've gone about this so that people can double check.
The last two print stmts print the following before the crash happens:
This seems to reference these tokens, as printed by the first stmt:
Not very useful for finding the cause, but knowing where it happens is a start for now.
Didn't get any further with debugging, but based on the insights I managed boil the shader down to this snippet that seems to crash in the same way:
Found the issue, it's in here:
github.com/hexops/mach@b14f8e69ee/src/sysgpu/shader/AstGen.zig (L2526-L2544)L2533 stores a slice of
astgen.refs.itemsnamedstruct_membersand uses it later in L2543. The problem is thatastgen.genExpr()in L2541 may invalidate this slice; in the MRE it's viagenExpr --> genCall --> node_rhs != .none --> token_tag == .k_array -->node_lhs != .none --> astgen.addRefList() --> astgen.refs.ensureUnusedCapacity().I'll submit a PR with a fix later.