Repository navigation
Use cfi_encoding instead of name in abi checking in miri - #164739
Conversation
|
Some changes occurred to the CTFE machinery Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri
cc @rust-lang/miri |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| #[cfi_encoding = "CfiEncoded"] | ||
| pub struct CfiEncoded1 { |
There was a problem hiding this comment.
CFI encodings are prefixed with the length of the tag.
| #[cfi_encoding = "CfiEncoded"] | |
| pub struct CfiEncoded1 { | |
| #[cfi_encoding = "10CfiEncoded"] | |
| pub struct CfiEncoded1 { |
There was a problem hiding this comment.
One has to do that manually...? What happens if I don't?
I thought this was just the tag so we don't have to worry about the rest of the encoding.
There was a problem hiding this comment.
All that happens is that it's only compatible with other structs also missing the integer prefix in the encoding.
I think it was done this way to also allow specifying the cfi encoding of e.g. a specific integer type, which do not have the integer prefix, putting them in a different "namespace" than structs.
There was a problem hiding this comment.
Oh so this can make a type look like an integer? Then I misunderstood what you said in rust-lang/unsafe-code-guidelines#626.
There was a problem hiding this comment.
So for this PR it doesn't really matter then. The logic in compiler/rustc_const_eval/src/interpret/call.rs is fine. Just the test is probably a bad example for how to use the attribute which ideally we should avoid.
| #[cfi_encoding = "CfiEncoded"] | |
| pub struct CfiEncoded1 { | |
| #[cfi_encoding = "10CfiEncoded"] // CFI encodings say that we should prefix the struct tag with its length | |
| pub struct CfiEncoded1 { |
There was a problem hiding this comment.
I changed the call.rs logic, to handle cases when a #[cfi_encoding] struct is matched with a normal struct. It's sad that call.rs should contain cfi specific logic, ideally we should have #[repr(C, tag = "CfiEncoded")] or something like that, but for now the new call.rs looks more correct to me than the previous one. An alternative is to reject compatibility between normal and #[cfi_encoding] structs, I can do that instead, if desired.
There was a problem hiding this comment.
An alternative is to reject compatibility between normal and #[cfi_encoding] structs, I can do that instead, if desired.
I'd prefer that TBH. That attribute seems quite cursed in its current behavior, good thing that it is still unstable.
|
r? me |
|
@rustbot author |
d7bd97f to
fb770c5
Compare
fb770c5 to
4b535e4
Compare
|
@rustbot review |
|
@bors r+ |
…uwer Rollup of 9 pull requests Successful merges: - #163743 (std: simplify the miri bypass of the stack overflow detection logic) - #164474 (core: implement `char::is_xid_{start|continue}`) - #164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`) - #164739 (Use cfi_encoding instead of name in abi checking in miri) - #162927 (stabilize ptr_cast_slice) - #163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers) - #164261 (Simplify MSYS check in is_terminal on Windows) - #164698 (Remove FCP from libs tracking checklist) - #164810 (Don't prioritize issues that require internal features)
Rollup merge of #164739 - hkalbasi:cfi_encoding_miri, r=RalfJung Use cfi_encoding instead of name in abi checking in miri Based on rust-lang/unsafe-code-guidelines#626 I think this patch helps in reflecting the current reality around abi compatibility and cfi better.
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#163743 (std: simplify the miri bypass of the stack overflow detection logic) - rust-lang/rust#164474 (core: implement `char::is_xid_{start|continue}`) - rust-lang/rust#164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`) - rust-lang/rust#164739 (Use cfi_encoding instead of name in abi checking in miri) - rust-lang/rust#162927 (stabilize ptr_cast_slice) - rust-lang/rust#163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers) - rust-lang/rust#164261 (Simplify MSYS check in is_terminal on Windows) - rust-lang/rust#164698 (Remove FCP from libs tracking checklist) - rust-lang/rust#164810 (Don't prioritize issues that require internal features)
Based on rust-lang/unsafe-code-guidelines#626 I think this patch helps in reflecting the current reality around abi compatibility and cfi better.