Skip to content

Commit

Permalink
default_alloc_error_hook: explain difference to default __rdl_oom in …
Browse files Browse the repository at this point in the history
…alloc
  • Loading branch information
RalfJung committed Apr 17, 2024
1 parent b758149 commit b5ec268
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ fn default_alloc_error_hook(layout: Layout) {
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
panic!("memory allocation of {} bytes failed", layout.size());
} else {
// This is the default path taken on OOM, and the only path taken on stable with std.
// Crucially, it does *not* call any user-defined code. That makes it different from the
// default `__rdl_oom` defined in alloc.
rtprintpanic!("memory allocation of {} bytes failed\n", layout.size());
}
}
Expand Down

0 comments on commit b5ec268

Please sign in to comment.