Skip to content

Commit cb13c4d

Browse files
committed
default_alloc_error_hook: explain difference to default __rdl_oom in alloc
1 parent b758149 commit cb13c4d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/std/src/alloc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ fn default_alloc_error_hook(layout: Layout) {
353353
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
354354
panic!("memory allocation of {} bytes failed", layout.size());
355355
} 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 there are no potential
358+
// reentrancy issues. That makes it different from the default `__rdl_oom` defined in alloc.
356359
rtprintpanic!("memory allocation of {} bytes failed\n", layout.size());
357360
}
358361
}

0 commit comments

Comments
 (0)