Skip to content

Commit eae45d8

Browse files
committed
fix the fragment_in_dst_padding_gets_overwritten test on s390x
on s390x 128bit types have a smaller alignment then on x86[^1]. This leads to smaller structs and therefore the write_unaligned will write outside of the structs boundary. To fix the test, change the trailing u32 into a u8. This will generate 7 trailing padding bytes on s390x and 15 on x86_64. Also change the start of the garbage data so it will span over x,y and padding: ``` s390x: XXXXXXXXXXXXXXXXY------- x86_64: XXXXXXXXXXXXXXXXY--------------- GGGGGGGG ``` [^1]: s390x ELF ABI Table 1.1, Page 12 https://github.com/IBM/s390x-abi
1 parent cc328c1 commit eae45d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/ui/consts/const-eval/ptr_fragments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ fn fragment_in_dst_padding_gets_overwritten() {
7373
struct Pair {
7474
x: u128,
7575
// at offset 16
76-
y: u64,
76+
y: u8,
7777
}
7878

7979
const C: MaybeUninit<Pair> = unsafe {
8080
let mut m = MaybeUninit::<Pair>::uninit();
8181
// Store pointer half-way into trailing padding.
82-
m.as_mut_ptr().byte_add(20).cast::<&i32>().write_unaligned(&0);
82+
m.as_mut_ptr().byte_add(14).cast::<&i32>().write_unaligned(&0);
8383
// Overwrite `m`.
8484
let val = Pair { x: 0, y: 0 };
8585
*m.as_mut_ptr() = val;

0 commit comments

Comments
 (0)