-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
stage2 llvm: pointer access with excess alignment, causing segfault #13232
Labels
Milestone
Comments
topolarity
added
bug
Observed behavior contradicts documented or intended behavior
frontend
Tokenization, parsing, AstGen, Sema, and Liveness.
labels
Oct 20, 2022
This LLVM IR is generated from this part of const type_slot_index = self.types.items.len;
try self.types.append(self.arena, .{
.Pointer = .{
.size = ptr.size,
.child = elem_type_ref.expr,
.has_align = ptr.flags.has_align,
.@"align" = @"align",
.has_addrspace = ptr.flags.has_addrspace,
.address_space = address_space,
.has_sentinel = ptr.flags.has_sentinel,
.sentinel = sentinel,
.is_mutable = ptr.flags.is_mutable,
.is_volatile = ptr.flags.is_volatile,
.has_bit_range = ptr.flags.has_bit_range,
.bit_start = bit_start,
.host_size = host_size,
},
}); |
In release modes, this memcpy sometimes gets lowered to a That segfault is preventing #13074 from passing CI. |
topolarity
changed the title
stage2 llvm: Pointer access with excess alignment
stage2 llvm: pointer access with excess alignment, causing segfault
Oct 20, 2022
Reduction: const Type = union(enum) {
Pointer: struct {
child: u32 align(16),
},
};
fn foo(x: Type) void {
_ = x;
}
test {
var child: u32 = 1;
foo(.{ .Pointer = .{ .child = child } });
} Generates an under-aligned define internal fastcc i16 @test22.test_0(ptr nonnull %0) unnamed_addr #0 !dbg !4390 {
Entry:
%1 = alloca %test22.Type, align 8
... |
topolarity
added a commit
to topolarity/zig
that referenced
this issue
Nov 1, 2022
Vexu
pushed a commit
that referenced
this issue
Nov 2, 2022
andrewrk
pushed a commit
that referenced
this issue
Nov 2, 2022
ryanschneider
pushed a commit
to ryanschneider/zig
that referenced
this issue
Nov 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zig Version
0.10.0-dev.4472+a4eb221b9
Steps to Reproduce
Build Zig and save the LLVM IR:
$ /build/zig2 build -p stage3_debug -Dstrip=true -Denable-llvm=true --verbose-llvm-ir 2>llvm_ir.txt
If you examine
Autodocs.walkInstruction
in the generated LLVM IR, you'll see this:Zig claims that
%2849
has alignment 16, but it actually has alignment 8.Expected Behavior
Alignment should be consistent between alloca and memcpy.
Actual Behavior
Alignments do not match.
The text was updated successfully, but these errors were encountered: