Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that handle_alloc_error may unwind #114898

Closed
kpreid opened this issue Aug 16, 2023 · 1 comment · Fixed by #115007
Closed

Clarify that handle_alloc_error may unwind #114898

kpreid opened this issue Aug 16, 2023 · 1 comment · Fixed by #115007
Assignees
Labels
A-allocators Area: Custom and system allocators A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@kpreid
Copy link
Contributor

kpreid commented Aug 16, 2023

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

@kpreid kpreid added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Aug 16, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-allocators Area: Custom and system allocators T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 16, 2023
@kpreid
Copy link
Contributor Author

kpreid commented Aug 19, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-allocators Area: Custom and system allocators A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants