Description
Calling the global allocator can in turn call arbitrary user-defined code
- if there is a custom global allocator (needs unsafe)
- if allocation fails, and there is one of
- a custom alloc hook (unstable)
-Zoom=panic
(unstable) plus a custom panic hook- a custom
#[alloc_error_handler]
(unstable, requires no_std) - a no_std library using alloc's default error hook (which panics) with a
#[panic_handler]
(may be possible on stable?)
It may just barely be the case that this cannot be triggered on stable today, depending on whether there is any way to actually run the liballoc default error hook on stable. I think the __rust_no_alloc_shim_is_unstable
symbol makes that impossible though? @bjorn3 might know.
Similar to #505, this can lead to reentrancy. That has caused real soundness questions: is it the responsibility of the allocator and the alloc error hook to never call into data structures except if they are declared reentrant, or is it the responsibility of every data structure to be resilient against reentrancy through the allocator? If they anyway have to be able to deal with reentrant panic hooks (due to #505), then is the extra possibility of reentrancy via the allocator even relevant?