-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
ptrToInt causes compiler segfault with microzig #15712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The file |
I trimmed the file. |
I happen to have a debug build, so if it'd help:
|
I was able to reproduce a segfault without microzig, I am not sure if this is the same bug, I added |
I think this one triggers #15513 |
pub fn main() !void {
var int_values: [5]u32 = .{0} ** 5;
var rx: [21]u8 = .{0} ** 21;
@memcpy(@ptrCast([*]u8, &int_values), rx[1..]);
} might be fixed with #15704. |
Yes this seems different, good call. |
Running the repo now produces:
The simplified example runs fine. |
Suggestion to close and, if needed, clarify with a new issue for feature detection. |
If you execute the command manually in a shell, you need to quote the file name as there is a space in it.
Yes, this was issue #15704 and is fixed.
The original issue stands, I sidetracked with the second example, but it had nothing to do with the original issue. I will try to bundle everything in a single file. |
const std = @import("std");
const assert = std.debug.assert;
pub fn Mmio(comptime PackedT: type) type {
const size = @bitSizeOf(PackedT);
const IntT = std.meta.Int(.unsigned, size);
return extern struct {
const Self = @This();
raw: IntT,
pub const underlying_type = PackedT;
};
}
pub const devices = struct {
pub const AES = @intToPtr(*volatile types.AES, 0x40026000);
};
pub const types = struct {
/// Advanced encryption standard hardware accelerator
pub const AES = extern struct {
/// control register
CR: Mmio(packed struct(u32) {
EN: u1,
padding: u31,
}),
};
};
pub fn main() !void {
var addr = @ptrToInt(&devices.AES.CR.raw);
_ = addr;
}
Triggers the bug (repo updated too).
|
Thanks for the reduction. No longer reproduces with |
Uh oh!
There was an error while loading. Please reload this page.
When compiling the following repo with zig version
0.11.0-dev.3138+87de8212ad
I get a compiler segfault.I was not able to isolate the issue to a simple example so I made a repo.
Repo: https://github.com/kuon/zig-bug-2
Error below.
I got a coredump, but my zig is not built in debug mode so it doesn't help much. If you cannot reproduce with my repo above, I'll rebuild in debug.
The text was updated successfully, but these errors were encountered: