Skip to content

Clarify that handle_alloc_error may unwind #114898

Closed
@kpreid

Description

@kpreid

Location

Summary

handle_alloc_error's documentation says:

Abort on memory allocation error or failure.

However,

  1. it is also specified to call the hook set with set_alloc_error_hook() (unstable) which per its example is permitted to panic and thereby potentially unwind, and
  2. per Announcing Rust 1.68.0, a “likely” future version of std might choose to panic on allocation failure instead.

Therefore, the documentation should be changed to not imply that this function will always abort, which could be taken as a promise that it will never unwind.

It also might be useful to expand the documentation of set_alloc_error_hook() so that the text and not only the example code specifies that it's okay to unwind from the hook (and what happens if you don't). (See also #56965 which is broader but doesn't mention this aspect.)

cc @xTachyon from discussion in Rust Community Discord

@rustbot label +A-allocators +T-libs-api

Metadata

Metadata

Assignees

Labels

A-allocatorsArea: Custom and system allocatorsA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions