File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
use std:: {
2
2
mem,
3
+ panic:: AssertUnwindSafe ,
3
4
sync:: atomic:: { AtomicBool , Ordering } ,
4
5
thread:: ThreadId ,
5
6
} ;
@@ -189,14 +190,19 @@ impl Runtime {
189
190
} )
190
191
} ) ;
191
192
193
+ // `DependencyGraph::block_on` does not panic, so we cannot enter an inconsistent state.
194
+ let dg = AssertUnwindSafe ( dg) ;
195
+ // `DependencyGraph::block_on` does not panic, nor does it read from query_mutex_guard, so
196
+ // we cannot enter an inconsistent state for this parameter.
197
+ let query_mutex_guard = AssertUnwindSafe ( query_mutex_guard) ;
192
198
let result = local_state. with_query_stack ( |stack| {
193
199
let ( new_stack, result) = DependencyGraph :: block_on (
194
- dg ,
200
+ { dg } . 0 ,
195
201
thread_id,
196
202
database_key,
197
203
other_id,
198
204
mem:: take ( stack) ,
199
- query_mutex_guard,
205
+ { query_mutex_guard } . 0 ,
200
206
) ;
201
207
* stack = new_stack;
202
208
result
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use crate::Cancelled;
19
19
use crate :: Id ;
20
20
use crate :: Revision ;
21
21
use std:: cell:: RefCell ;
22
+ use std:: panic:: UnwindSafe ;
22
23
23
24
/// State that is specific to a single execution thread.
24
25
///
@@ -102,8 +103,7 @@ impl ZalsaLocal {
102
103
/// Executes a closure within the context of the current active query stacks.
103
104
pub ( crate ) fn with_query_stack < R > (
104
105
& self ,
105
- // FIXME: We ought to require `UnwindSafe` here to prove that `ZalsaLocal: RefUnwindSafe`
106
- c : impl FnOnce ( & mut Vec < ActiveQuery > ) -> R , /*+ UnwindSafe */
106
+ c : impl UnwindSafe + FnOnce ( & mut Vec < ActiveQuery > ) -> R ,
107
107
) -> R {
108
108
c ( self . query_stack . borrow_mut ( ) . as_mut ( ) )
109
109
}
@@ -285,9 +285,10 @@ impl ZalsaLocal {
285
285
}
286
286
}
287
287
288
- // Okay to implement as `ZalsaLocal`` is !Sync and FIXME: See `Self::with_query_stack`
288
+ // Okay to implement as `ZalsaLocal`` is !Sync
289
289
// - `most_recent_pages` can't observe broken states as we cannot panic such that we enter an
290
290
// inconsistent state
291
+ // - neither can `query_stack` as we require the closures accessing it to be `UnwindSafe`
291
292
impl std:: panic:: RefUnwindSafe for ZalsaLocal { }
292
293
293
294
/// Summarizes "all the inputs that a query used"
You can’t perform that action at this time.
0 commit comments