File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,11 @@ pub fn set_hook(hook: Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>) {
124
124
panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
125
125
}
126
126
127
+ // SAFETY:
128
+ //
129
+ // - `HOOK` can only be modified while holding write access to `HOOK_LOCK`.
130
+ // - The argument of `Box::from_raw` is always a valid pointer that was created using
131
+ // `Box::into_raw`.
127
132
unsafe {
128
133
let guard = HOOK_LOCK . write ( ) ;
129
134
let old_hook = HOOK ;
@@ -173,6 +178,11 @@ pub fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send> {
173
178
panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
174
179
}
175
180
181
+ // SAFETY:
182
+ //
183
+ // - `HOOK` can only be modified while holding write access to `HOOK_LOCK`.
184
+ // - The argument of `Box::from_raw` is always a valid pointer that was created using
185
+ // `Box::into_raw`.
176
186
unsafe {
177
187
let guard = HOOK_LOCK . write ( ) ;
178
188
let hook = HOOK ;
@@ -229,6 +239,11 @@ where
229
239
panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
230
240
}
231
241
242
+ // SAFETY:
243
+ //
244
+ // - `HOOK` can only be modified while holding write access to `HOOK_LOCK`.
245
+ // - The argument of `Box::from_raw` is always a valid pointer that was created using
246
+ // `Box::into_raw`.
232
247
unsafe {
233
248
let guard = HOOK_LOCK . write ( ) ;
234
249
let old_hook = HOOK ;
You can’t perform that action at this time.
0 commit comments