-
Notifications
You must be signed in to change notification settings - Fork 239
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
Segfaults when builder is called without setting its position first #425
Comments
I wanna say this is a known issue but I can't find a ticket for it lol. Not sure the LLVM api has a safe way for us to verify if a position has been set |
I was about to open an issue but found this one. Minimal reprod: fn main() {
let context = inkwell::context::Context::create();
let builder = context.create_builder();
// [1] 70215 segmentation fault (core dumped)
builder.build_alloca(context.i64_type(), &"n");
} inkwell = { version = "0.2.0", features = ["llvm15-0"] } |
Perhaps Inkwell can store a state of BB, so that it has a runtime error? Or better yet, a type-state of some sort? |
Yeah, I've thought about using type state for this before but we'd have to figure out which methods are valid for each state and there are a lot of builder methods |
I agree, it would be complicated to implement type state. To implement type state based safety, perhaps a builer pattern can be implemented for the However, as someone who uses Inkwell in my own projects, I think this would be cumbersome from an API useability point of view. For example, a For those reasons, I am think runtime assertions to ensure safety by adding state to the |
Describe the Bug
Program compiles successfully but segfaults, if builder position is not set to some BB.
To Reproduce
Expected Behavior
This should at least produce a "controled" runtime error.
LLVM Version (please complete the following information):
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: