Rollup merge of #97707 - Nilstrieb:data-structures-ub, r=cjgillot
Improve soundness of rustc_data_structures Make it runnable in miri by adding some ignores and changing N in miri. Also fix a stacked borrows issue in sip128.
This commit is contained in:
commit
01453219de
4 changed files with 12 additions and 2 deletions
|
@ -15,7 +15,9 @@ fn test_encode() {
|
|||
test(u64::MAX as u128, base);
|
||||
test(u128::MAX, base);
|
||||
|
||||
for i in 0..1_000 {
|
||||
const N: u128 = if cfg!(miri) { 10 } else { 1000 };
|
||||
|
||||
for i in 0..N {
|
||||
test(i * 983, base);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,10 @@ fn test_deep_linear() {
|
|||
v
|
||||
…
|
||||
*/
|
||||
#[cfg(not(miri))]
|
||||
const NR_NODES: usize = 1 << 14;
|
||||
#[cfg(miri)]
|
||||
const NR_NODES: usize = 1 << 3;
|
||||
let mut nodes = vec![];
|
||||
for i in 1..NR_NODES {
|
||||
nodes.push((i - 1, i));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// FIXME: owning_ref is not sound under stacked borrows. Preferably, get rid of it.
|
||||
#[cfg(not(miri))]
|
||||
mod owning_ref {
|
||||
use super::super::OwningRef;
|
||||
use super::super::{BoxRef, Erased, ErasedBoxRef, RcRef};
|
||||
|
@ -361,6 +363,8 @@ mod owning_handle {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: owning_ref is not sound under stacked borrows. Preferably, get rid of it.
|
||||
#[cfg(not(miri))]
|
||||
mod owning_ref_mut {
|
||||
use super::super::BoxRef;
|
||||
use super::super::{BoxRefMut, Erased, ErasedBoxRefMut, OwningRefMut};
|
||||
|
|
|
@ -255,8 +255,9 @@ impl SipHasher128 {
|
|||
// elements from spill (at most LEN - 1 bytes could have overflowed
|
||||
// into the spill). The memcpy call is optimized away because the size
|
||||
// is known. And the whole copy is optimized away for LEN == 1.
|
||||
let dst = self.buf.as_mut_ptr() as *mut u8;
|
||||
let src = self.buf.get_unchecked(BUFFER_SPILL_INDEX) as *const _ as *const u8;
|
||||
ptr::copy_nonoverlapping(src, self.buf.as_mut_ptr() as *mut u8, LEN - 1);
|
||||
ptr::copy_nonoverlapping(src, dst, LEN - 1);
|
||||
|
||||
// This function should only be called when the write fills the buffer.
|
||||
// Therefore, when LEN == 1, the new `self.nbuf` must be zero.
|
||||
|
|
Loading…
Add table
Reference in a new issue