Fix broken test after toolchain update

Summary: These tests did unaligned reads/writes, which can produce a `SIGABRT` instead of a `SIGSEGV`. Simply align the reads/writes to 8 bytes to fix the tests.

Reviewed By: JakobDegen, dtolnay

Differential Revision: D53597637

fbshipit-source-id: e2ede420b6249223569af6d89d43a47438967ced
This commit is contained in:
Jason White 2024-02-08 20:02:47 -08:00 committed by Facebook GitHub Bot
parent 06f05e10f4
commit 17e8f64e94

View file

@ -231,8 +231,8 @@ fn i_should_segfault() {
use reverie_ptrace::testing::test_fn;
let (output, _) = test_fn::<NoopTool, _>(|| {
unsafe {
let invalid_ptr = 0x5u64 as *mut u64;
invalid_ptr.write(0xdeadbeefu64);
let invalid_ptr = 0x8u64 as *mut u64;
invalid_ptr.write_volatile(0xdeadbeefu64);
};
})
.unwrap();
@ -246,8 +246,8 @@ fn i_should_segfault_2() {
use reverie_ptrace::testing::test_fn;
pub fn do_segfault() {
let invalid_ptr = 0x1234 as *const usize;
let result = unsafe { invalid_ptr.read() };
let invalid_ptr = 0x8u64 as *const usize;
let result = unsafe { invalid_ptr.read_volatile() };
// Print so the above doesn't get optimized out. We will never get here
// because the above segfaults.
println!("{}", result);