-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Incorrect handling of come invalid inline assembly constraints #54130
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
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-inline-assembly
Area: Inline assembly (`asm!(…)`)
C-bug
Category: This is a bug.
Comments
I am unable to reproduce this issue:
Later versions, including the Is there something that I'm missing? |
Sorry, an extra comma sneaked in while trying to get the code formatting on Github. The reproducing code is:
|
Thanks, I can now reproduce it. Backtrace of the segfault:
|
bors
added a commit
that referenced
this issue
Sep 28, 2018
codegen_llvm: check inline assembly constraints with LLVM ---%<--- Hey all, As issue #54130 highlights, constraints are not checked and passing bad constraints to LLVM can crash it since a `Verify()` call is placed inside an assertion (see: `src/llvm/lib/IR/InlineAsm.cpp:39`). As this is my first PR to the Rust compiler (woot! 🎉), there might be better ways of achieving this result. In particular, I am not too happy about generating an error in codegen; it would be much nicer if we did it earlier. However, @rkruppe [noted on IRC](https://botbot.me/mozilla/rustc/2018-09-25/?msg=104791581&page=1) that this should be fine for an unstable feature and a much better solution than the _status quo_, which is an ICE. Thanks! --->%--- LLVM provides a way of checking whether the constraints and the actual inline assembly make sense. This commit introduces a check before emitting code for the inline assembly. If LLVM rejects the inline assembly (or its constraints), then the compiler emits an error E0668 ("malformed inline assembly"). Fixes: #54130 Signed-off-by: Levente Kurusa \<[email protected]\>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-inline-assembly
Area: Inline assembly (`asm!(…)`)
C-bug
Category: This is a bug.
Short summary: When an inline assembly constraint lacks its closing curly brace, the compiler segfaults when optimizing, and accepts the code when not optimizing.
Steps to reproduce:
main.rs
):(note the missing closing brace in the constraint)
rustc -O main.rs
, on nightly because we use a feature flag)rustc main.rs
)Expected result
Error message that the constraint is not well-formed
Actual result
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: