File tree 1 file changed +13
-1
lines changed
compiler/rustc_middle/src/mir/interpret
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,21 @@ impl<'s> AllocDecodingSession<'s> {
206
206
( alloc_kind, decoder. position ( ) )
207
207
} ) ;
208
208
209
+ // We are going to hold this lock during the entire decoding of this allocation, which may
210
+ // require that we decode other allocations. This cannot deadlock for two reasons:
211
+ //
212
+ // At the time of writing, it is only possible to create an allocation that contains a pointer
213
+ // to itself using the const_allocate intrinsic (which is for testing only), and even attempting
214
+ // to evaluate such consts blows the stack. If we ever grow a mechanism for producing
215
+ // cyclic allocations, we will need a new strategy for decoding that doesn't bring back
216
+ // https://github.com/rust-lang/rust/issues/126741.
217
+ //
218
+ // It is also impossible to create two allocations (call them A and B) where A is a pointer to B, and B
219
+ // is a pointer to A, because attempting to evaluate either of those consts will produce a
220
+ // query cycle, failing compilation.
221
+ let mut entry = self . state . decoding_state [ idx] . lock ( ) ;
209
222
// Check the decoding state to see if it's already decoded or if we should
210
223
// decode it here.
211
- let mut entry = self . state . decoding_state [ idx] . lock ( ) ;
212
224
if let State :: Done ( alloc_id) = * entry {
213
225
return alloc_id;
214
226
}
You can’t perform that action at this time.
0 commit comments