File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,12 @@ fn default_alloc_error_hook(layout: Layout) {
353
353
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
354
354
panic ! ( "memory allocation of {} bytes failed" , layout. size( ) ) ;
355
355
} else {
356
+ // This is the default path taken on OOM, and the only path taken on stable with std.
357
+ // Crucially, it does *not* call any user-defined code, and therefore users do not have to
358
+ // worry about allocation failure causing reentrancy issues. That makes it different from
359
+ // the default `__rdl_oom` defined in alloc (i.e., the default alloc error handler that is
360
+ // called when there is no `#[alloc_error_handler]`), which triggers a regular panic and
361
+ // thus can invoke a user-defined panic hook, executing arbitrary user-defined code.
356
362
rtprintpanic ! ( "memory allocation of {} bytes failed\n " , layout. size( ) ) ;
357
363
}
358
364
}
You can’t perform that action at this time.
0 commit comments