-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
panic bug in printed trace #9472
Copy link
Copy link
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.
Milestone
Description
I'm on macos 10.15.7 using the binary release zig-macos-x86_64-0.8.0 and can't reproduce the examples in the language documentation that contain a panic. Every example I have tried has printed a trace that points to the wrong location.
e.g. when I try to test the following example
const std = @import("std");
test "pointer alignment safety" {
var array align(4) = [_]u32{ 0x11111111, 0x11111111 };
const bytes = std.mem.sliceAsBytes(array[0..]);
try std.testing.expect(foo(bytes) == 0x11111111);
}
fn foo(bytes: []u8) u32 {
const slice4 = bytes[1..5];
const int_slice = std.mem.bytesAsSlice(u32, @alignCast(4, slice4));
return int_slice[0];
}I get
myers-mac-28:genart broaddus$ zig test src/test2.zig
thread 2628295 panic: incorrect alignment"...
/Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/lib/std/debug.zig:272:92: 0x104a5d5f1 in std.debug.panicExtra (test)
stderr.print("thread {d} panic: ", .{current_thread_id}) catch os.abort();
^
/Users/broaddus/Desktop/ProjectsPersonal/zig/genart/src/test2.zig:6:5: 0x104a5b3c9 in test "pointer alignment safety" (test)
try std.testing.expect(foo(bytes) == 0x11111111);
^
/Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/lib/std/special/test_runner.zig:34:71: 0x104a5da09 in std.special.main (test)
const root_node = progress.start("Test", test_fn_list.len) catch |err| switch (err) {
^
/Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/lib/std/fmt.zig:242:20: 0x104a96158 in std.fmt.format (test)
options = .{};
^
/Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/lib/std/debug.zig:0:0: 0x104a5f727 in ??? (test)
/Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/lib/std/debug.zig:65:38: 0x104a5f665 in std.debug.print (test)
const held = stderr_mutex.acquire();
^
???:?:?: 0x7fff736a9cc8 in ??? (???)
???:?:?: 0x1 in ??? (???)
error: the following test command crashed:
src/zig-cache/o/503d780bce0fcc566a71b0b9b18101d4/test /Users/broaddus/Downloads/zig-macos-x86_64-0.8.0/zigwhich doesn't point to the correct location of the panic and differs from the documented example here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.