-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
LLVM assertion failed on mac llvm10 debug build #13205
Comments
I have reduced it to: lib LibFoo
union U
x : Int8
y : Int16
end
end
abstract class Foo
end
class Bar < Foo
@x : LibFoo::U?
end
Bar.new |
Here with llvm 11.1 and x86 mac it doesn't reproduce. |
Just built LLVM in debug mode and this spec hits the same assertion failure: crystal/spec/compiler/codegen/debug_spec.cr Lines 51 to 65 in 7f46589
The reduction above broke in OP's setup because of |
Managed to hit this again with a debug build of LLVM 16.0.0. This time the lib Foo
union Bar
a : Int32
b : Int16
end
end
Foo::Bar.new It makes sense because C unions generated by Crystal only have 1 LLVM struct member for alignment and 1 optional member for padding. In this case crystal/src/compiler/crystal/codegen/debug.cr Lines 150 to 159 in d1fd6c8
All lib unions with 3 or more members break debug builds regardless of the member types, and More generally, lib Foo
union Bar
x : Int32
y : Int16
z : Int8
end
end
offsetof(Foo::Bar, @x) # => 0
offsetof(Foo::Bar, @y) # => 110689
# internal error
# offsetof(Foo::Bar, @z) # Invalid Int32: "93921398392816" (ArgumentError) This offset must always be 0 because all lib union members are less aligned than the whole union itself. |
This was confirmed to be fixed with LLVM 10.0.1, and I don't think LLVM 10.0.0 as used in the OP would be any different. |
Bug Report
Using the prebuilt 1.7.3 binaries from the releases, I get an error on the mac build (but not linux) when doing a --debug build (but not normal or release). This is maybe related to #12589, but the llvm versions are different.
This is on CrunchyData/bridge-cli@cafe97f where I just added a nix flake to pull in the precompiled version from this repo's release page. So you should be able to do
nix develop
thencrystal build src/cli.cr --debug
to get the same error:On linux where its
Crystal 1.7.3 [d61a01e18] (2023-03-07) LLVM: 13.0.1
the problem doesn't reproduce.I'm not sure if it's useful but here is some lldb stuff
first 20 frames of the backtrace
There are almost 500 frames, so I attached them.
backtrace.txt
The text was updated successfully, but these errors were encountered: