File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
compiler/rustc_middle/src/mir/interpret Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,16 @@ impl<'s> AllocDecodingSession<'s> {
206206 ( alloc_kind, decoder. position ( ) )
207207 } ) ;
208208
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+ // It is impossible to create an allocation that contains a pointer to itself and thus
212+ // deadlock with a single thread, because attempting to create such a pointer immediately
213+ // blows the stack.
214+ // It is also impossible to create two allocations (call them A and B) where A is a pointer to B, and B
215+ // is a pointer to A, because const eval itself rejects such cycles.
216+ let mut entry = self . state . decoding_state [ idx] . lock ( ) ;
209217 // Check the decoding state to see if it's already decoded or if we should
210218 // decode it here.
211- let mut entry = self . state . decoding_state [ idx] . lock ( ) ;
212219 if let State :: Done ( alloc_id) = * entry {
213220 return alloc_id;
214221 }
You can’t perform that action at this time.
0 commit comments