-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustc_codegen_llvm
should mark more of its internal methods as unsafe
#131562
Comments
Yeah I also ran into this, e.g. calling |
In my case, I was getting far worse than segfaults: illegal instructions. And worse, since it was UB, the resulting errors did not occur with a useful stack trace pointing out where the error was, which is why I mentioned assertions being so helpful. |
TBH I don't remember whether it was SEGFAULT or SIGILL... it was an abrupt abort and I debugged it by staring hard at my code until I realized where the wrong call must be.^^ |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-low |
Triage: this is probably more of a tracking issue for |
Not a soundness hole in the language. |
Just following up from this comment I made here: #85532 (comment)
While LLVM compiled with asserts ensures that no undefined behaviour occurs when calling methods, it does not when compiled without asserts, and this should really be reflected in the signatures for all the various internal methods that just call out to LLVM FFI.
Right now, it's very easy to trigger UB when you're writing an intrinsic, and while it's common for C functions to have all sorts of undocumented preconditions, we should not extend this habit into Rust.
For example,
const_array
will trivially trigger UB if any of theValue
s passed into it are not actually constant:And
extract_value
will trigger UB if the index is out of bounds for the givenValue
:Whereas something like
type_i1
is fine and will always be safe to call:Sure, this will "introduce" unsafe code to, for example, the intrinsics lowering, but the code was already unsafe, and this is just documenting that.
@rustbot label T-compiler
The text was updated successfully, but these errors were encountered: