mirror of
https://codeberg.org/ziglang/zig
synced 2026-11-18 07:05:05 +00:00
Minimal repro:
```Zig
fn foo(slice: []const u8, arr: *const [34]u8) void {
_ = slice;
_ = arr;
}
export fn main() void {
const data: []const u8 = "dummy";
const arr: [34]u8 = @splat(1);
foo(data, &arr);
}
```
With `zig build-obj -target spirv64-vulkan repro.zig` on a debug build causes a nasty linker error:
```
thread 1389148 panic: index out of bounds: index 3021285136, len 81
zig/src/link/Spirv/Flush.zig:78:28: 0x2368081 in copy (main.zig)
if (input.marks[word] != input.mark) {
...
```
Seems like it's coming from call instruction emitting. `params` is reserved `id_scratch` up front, but the slice that's returned can be invalidated by (at least) a path in `cg.resolve()`, as it can also use `id_scratch`. This causes a dangling pointer, which writes some garbage data IDs, and badaboom.
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37560
Reviewed-by: Ali Cheraghi <alichraghi@noreply.codeberg.org>
8535 lines
345 KiB
8535 lines
345 KiB