File tree 2 files changed +29
-4
lines changed
tests/pass/stacked-borrows
2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,14 @@ impl Stack {
43
43
pub fn retain ( & mut self , tags : & FxHashSet < SbTag > ) {
44
44
let mut first_removed = None ;
45
45
46
- // For stacks with a known bottom, we never consider removing the bottom-most tag, because
47
- // that is the base tag which exists whether or not there are any pointers to the
48
- // allocation.
49
- let mut read_idx = if self . unknown_bottom . is_some ( ) { 0 } else { 1 } ;
46
+ // We never consider removing the bottom-most tag. For stacks without an unknown
47
+ // bottom this preserves the base tag.
48
+ // Note that the algorithm below is based on considering the tag at read_idx - 1,
49
+ // so precisely considering the tag at index 0 for removal when we have an unknown
50
+ // bottom would complicate the implementation. The simplification of not considering
51
+ // it does not have a significant impact on the degree to which the GC mititages
52
+ // memory growth.
53
+ let mut read_idx = 1 ;
50
54
let mut write_idx = read_idx;
51
55
while read_idx < self . borrows . len ( ) {
52
56
let left = self . borrows [ read_idx - 1 ] ;
Original file line number Diff line number Diff line change
1
+ //@compile-flags: -Zmiri-permissive-provenance
2
+ #![ feature( strict_provenance) ]
3
+
4
+ use std:: ptr;
5
+
6
+ fn main ( ) {
7
+ let mut v = 1u8 ;
8
+ let ptr = & mut v as * mut u8 ;
9
+
10
+ // Expose the allocation and use the exposed pointer, creating an unknown bottom
11
+ unsafe {
12
+ let p: * mut u8 = ptr:: from_exposed_addr :: < u8 > ( ptr. expose_addr ( ) ) as * mut u8 ;
13
+ * p = 1 ;
14
+ }
15
+
16
+ // Pile on a lot of SharedReadOnly at the top of the stack
17
+ let r = & v;
18
+ for _ in 0 ..1024 {
19
+ let _x = & * r;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments