@@ -354,6 +354,9 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
354
354
355
355
unsafe impl < ' a > BoxMeUp for PanicPayload < ' a > {
356
356
fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
357
+ // We do two allocations here, unfortunately. But (a) they're required with the current
358
+ // scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
359
+ // begin_panic below).
357
360
let contents = mem:: take ( self . fill ( ) ) ;
358
361
Box :: into_raw ( Box :: new ( contents) )
359
362
}
@@ -363,11 +366,6 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
363
366
}
364
367
}
365
368
366
- // We do two allocations here, unfortunately. But (a) they're
367
- // required with the current scheme, and (b) we don't handle
368
- // panic + OOM properly anyway (see comment in begin_panic
369
- // below).
370
-
371
369
let loc = info. location ( ) . unwrap ( ) ; // The current implementation always returns Some
372
370
let msg = info. message ( ) . unwrap ( ) ; // The current implementation always returns Some
373
371
rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , info. message ( ) , loc) ;
@@ -389,12 +387,6 @@ pub fn begin_panic<M: Any + Send>(msg: M, #[cfg(bootstrap)] _: &(&str, u32, u32)
389
387
unsafe { intrinsics:: abort ( ) }
390
388
}
391
389
392
- // Note that this should be the only allocation performed in this code path.
393
- // Currently this means that panic!() on OOM will invoke this code path,
394
- // but then again we're not really ready for panic on OOM anyway. If
395
- // we do start doing this, then we should propagate this allocation to
396
- // be performed in the parent of this thread instead of the thread that's
397
- // panicking.
398
390
rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , None , Location :: caller ( ) ) ;
399
391
400
392
struct PanicPayload < A > {
@@ -409,6 +401,11 @@ pub fn begin_panic<M: Any + Send>(msg: M, #[cfg(bootstrap)] _: &(&str, u32, u32)
409
401
410
402
unsafe impl < A : Send + ' static > BoxMeUp for PanicPayload < A > {
411
403
fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
404
+ // Note that this should be the only allocation performed in this code path. Currently
405
+ // this means that panic!() on OOM will invoke this code path, but then again we're not
406
+ // really ready for panic on OOM anyway. If we do start doing this, then we should
407
+ // propagate this allocation to be performed in the parent of this thread instead of the
408
+ // thread that's panicking.
412
409
let data = match self . inner . take ( ) {
413
410
Some ( a) => Box :: new ( a) as Box < dyn Any + Send > ,
414
411
None => process:: abort ( ) ,
0 commit comments