File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 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>) {
124124 panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
125125 }
126126
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`.
127132 unsafe {
128133 let guard = HOOK_LOCK . write ( ) ;
129134 let old_hook = HOOK ;
@@ -173,6 +178,11 @@ pub fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send> {
173178 panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
174179 }
175180
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`.
176186 unsafe {
177187 let guard = HOOK_LOCK . write ( ) ;
178188 let hook = HOOK ;
@@ -229,6 +239,11 @@ where
229239 panic ! ( "cannot modify the panic hook from a panicking thread" ) ;
230240 }
231241
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`.
232247 unsafe {
233248 let guard = HOOK_LOCK . write ( ) ;
234249 let old_hook = HOOK ;
You can’t perform that action at this time.
0 commit comments