-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
fix test_new_from_file_crafted_executable for m1 #26009
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -899,16 +899,16 @@ pub mod tests { | |
let accounts = av.accounts(0); | ||
let account = accounts.first().unwrap(); | ||
|
||
// upper 7-bits are not 0, so sanitization should fail | ||
assert!(!account.sanitize_executable()); | ||
|
||
// we can observe crafted value by ref | ||
{ | ||
let executable_bool: &bool = &account.account_meta.executable; | ||
// Depending on use, *executable_bool can be truthy or falsy due to direct memory manipulation | ||
// assert_eq! thinks *executable_bool is equal to false but the if condition thinks it's not, contradictorily. | ||
// Depending on use, *executable_bool can be truthy or falsy due to direct memory manipulation. | ||
// Behavior is dependent on compiler. | ||
// assert! thinks !*executable_bool is true, for all compilers | ||
assert!(!*executable_bool); | ||
const FALSE: bool = false; // keep clippy happy | ||
if *executable_bool == FALSE { | ||
panic!("This didn't occur if this test passed."); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you restore this with the intent isn't clear but this test is checking the existence of undefined behavior around bool inside rustc (or llvm): https://doc.rust-lang.org/reference/types/boolean.html:
as you know, we're not relying on the UB (bit pattern other than 0x00 and 0x01 for any ad-hoc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, re-added the if/panic, but disabled it for aarch64. |
||
assert_eq!(*account.ref_executable_byte(), crafted_executable); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
my memory is vague. but i think i tried to add this assertion, but i couldn't because the ub assertion below stopped working correctly back then. (welcome to UB land. lol)
if today's build toolchain doesn't negatively affect the UB detection code, please leave to
assert!
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^passing CI with the assert left there.