You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This minimal repro only works when there are a wrong number of arguments, but it also prevents real programs from compiling. I encountered it when trying to build the new mach/gpu package with stage2:
pubinlinefninstanceRequestAdapter() void {
}
pubinlinefnrequestAdapter(
comptimecallback: fn () callconv(.Inline) void,
) void {
_= (struct {
pubfncallback() callconv(.C) void {
callback();
}
}).callback;
instanceRequestAdapter(undefined); // note wrong number of arguments here
}
inlinefnfoo() void {}
test {
requestAdapter(foo);
}
Expected Behavior
Stage1 produces a proper error:
rm -rf ./zig-cache && zig build test
./src/main.zig:12:27: error: expected 0 argument(s), found 1
instanceRequestAdapter(undefined); // note wrong number of arguments here
^
Actual Behavior
Stage2 gives an ICE:
% zig build test -fno-stage1
thread 2238175 panic: incorrect alignment
Analyzing /Users/slimsag/Desktop/zigtest/src/main.zig: main.zig:requestAdapter__struct_904.callback
%19 = dbg_block_begin())
%20 = dbg_stmt(2, 13)
> %22 = closure_get(%21)
%23 = dbg_stmt(2, 21)
%25 = dbg_block_end())
%24 = call(nodiscard .auto, %22, [])
%26 = ret_tok(@Zir.Inst.Ref.void_value)
For full context, use the command
zig ast-check -t /Users/slimsag/Desktop/zigtest/src/main.zig
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/hash_map.zig:935:13: 0x100f33d93 in header (zig)
self.available = 0;
^
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/hash_map.zig:949:31: 0x100f339c3 in capacity (zig)
^
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/hash_map.zig:1135:39: 0x1013840e7 in getPtrAdapted__anon_214370 (zig)
// If you get a compile error on this line, it means that your generic hash
^
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/hash_map.zig:1234:38: 0x1011be85b in getPtrContext (zig)
^
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/hash_map.zig:1231:38: 0x1010345ef in getPtr (zig)
}
^
/Users/slimsag/Desktop/zig/src/Sema.zig:13451:34: 0x100e344df in zirClosureGet (zig)
if (scope.captures.getPtr(inst_data.inst)) |tv| {
^
/Users/slimsag/Desktop/zig/src/Sema.zig:720:68: 0x100cd1cf7 in analyzeBodyInner (zig)
.closure_get => try sema.zirClosureGet(block, inst),
^
/Users/slimsag/Desktop/zig/src/Sema.zig:604:30: 0x100cd0977 in analyzeBody (zig)
_ = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
^
/Users/slimsag/Desktop/zig/src/Module.zig:5501:21: 0x100b7817b in analyzeFnBody (zig)
sema.analyzeBody(&inner_block, fn_info.body) catch |err| switch (err) {
^
/Users/slimsag/Desktop/zig/src/Module.zig:4212:40: 0x1009e1d17 in ensureFuncBodyAnalyzed (zig)
var air = mod.analyzeFnBody(func, sema_arena) catch |err| switch (err) {
^
/Users/slimsag/Desktop/zig/src/Compilation.zig:2966:42: 0x1009e076b in processOneJob (zig)
module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
^
/Users/slimsag/Desktop/zig/src/Compilation.zig:2898:30: 0x10090ab1f in performAllTheWork (zig)
try processOneJob(comp, work_item);
^
/Users/slimsag/Desktop/zig/src/Compilation.zig:2238:31: 0x10090808b in update (zig)
try comp.performAllTheWork(main_progress_node);
^
/Users/slimsag/Desktop/zig/src/main.zig:3327:20: 0x10092aba3 in updateModule (zig)
try comp.update();
^
/Users/slimsag/Desktop/zig/src/main.zig:3016:17: 0x100753c87 in buildOutputType (zig)
updateModule(gpa, comp, hook) catch |err| switch (err) {
^
/Users/slimsag/Desktop/zig/src/main.zig:236:31: 0x10073115b in mainArgs (zig)
return buildOutputType(gpa, arena, args, .zig_test);
^
/Users/slimsag/Desktop/zig/src/main.zig:174:20: 0x100730947 in main (zig)
return mainArgs(gpa, arena, args);
^
/Users/slimsag/Desktop/zig/build/stage2/lib/zig/std/start.zig:574:37: 0x1007321ab in main (zig)
},
^
???:?:?: 0x10cfb10f3 in ??? (???)
???:?:?: 0x1b63ffffffffffff in ??? (???)
error: test...
error: The following command terminated unexpectedly:
/Users/slimsag/Desktop/zig/build/stage3/bin/zig test -fno-stage1 /Users/slimsag/Desktop/zigtest/src/main.zig --cache-dir /Users/slimsag/Desktop/zigtest/zig-cache --global-cache-dir /Users/slimsag/.cache/zig --name test --enable-cache
error: the following build command failed with exit code 6:
/Users/slimsag/Desktop/zigtest/zig-cache/o/e2f58f24df344dd1c10a8ecbac71bfd3/build /Users/slimsag/Desktop/zig/build/stage3/bin/zig /Users/slimsag/Desktop/zigtest /Users/slimsag/Desktop/zigtest/zig-cache /Users/slimsag/.cache/zig test -fno-stage1 -fno-stage1
The text was updated successfully, but these errors were encountered:
slimsag
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Aug 12, 2022
slimsag
changed the title
stage2: ICE with inlined functions / wrong number of parameters
stage3: ICE with inlined functions / wrong number of parameters
Aug 16, 2022
Previously if a decl failed its capture scope would be deallocated and
set to undefined which would then lead to invalid dereference in
`zirClosureGet`. To avoid this set the capture scope to a special
failed state and fail the current decl with dependency failure if
the failed state is encountered in `zirClosureGet`.
Closesziglang#12433Closesziglang#12530Closesziglang#12593
Previously if a decl failed its capture scope would be deallocated and
set to undefined which would then lead to invalid dereference in
`zirClosureGet`. To avoid this set the capture scope to a special
failed state and fail the current decl with dependency failure if
the failed state is encountered in `zirClosureGet`.
Closesziglang#12433Closesziglang#12530Closesziglang#12593
Zig Version
0.10.0-dev.3577+b3922289b + stage3 (
build/stage3/bin/zig
)Steps to Reproduce
This minimal repro only works when there are a wrong number of arguments, but it also prevents real programs from compiling. I encountered it when trying to build the new
mach/gpu
package with stage2:Expected Behavior
Stage1 produces a proper error:
Actual Behavior
Stage2 gives an ICE:
The text was updated successfully, but these errors were encountered: