Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace {Alloc,GlobalAlloc}::oom with a lang item. #50144
Conversation
rust-highfive
assigned
alexcrichton
Apr 21, 2018
rust-highfive
added
the
S-waiting-on-review
label
Apr 21, 2018
sfackler
referenced this pull request
Apr 21, 2018
Closed
Tracking issue for the GlobalAlloc trait and related APIs #49668
mattico
reviewed
Apr 21, 2018
| name: "oom", | ||
| inputs: &[], | ||
| output: AllocatorTy::Bang, | ||
| }, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors: r+ That was easier than I thought it would be! |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Apr 21, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-author
and removed
S-waiting-on-bors
labels
Apr 22, 2018
sfackler
added some commits
Apr 21, 2018
sfackler
force-pushed the
sfackler:oom-lang-item
branch
from
b301d05
to
5969712
Apr 22, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Apr 22, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 22, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 5969712
into
rust-lang:master
Apr 22, 2018
eddyb
reviewed
Apr 25, 2018
| @@ -59,7 +59,7 @@ unsafe impl<T> Alloc for T where T: CoreAlloc { | |||
| } | |||
|
|
|||
| fn oom(&mut self, _: AllocErr) -> ! { | |||
| CoreAlloc::oom(self) | |||
| unsafe { ::core::intrinsics::abort() } | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eddyb
reviewed
Apr 25, 2018
| @@ -303,7 +303,8 @@ language_item_table! { | |||
|
|
|||
| ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn; | |||
| BoxFreeFnLangItem, "box_free", box_free_fn; | |||
| DropInPlaceFnLangItem, "drop_in_place", drop_in_place_fn; | |||
| DropInPlaceFnLangItem, "drop_in_place", drop_in_place_fn; | |||
| OomLangItem, "oom", oom; | |||
This comment has been minimized.
This comment has been minimized.
sfackler
deleted the
sfackler:oom-lang-item
branch
Apr 25, 2018
SimonSapin
referenced this pull request
Apr 27, 2018
Merged
Upgrade to rustc 1.27.0-nightly (7f3444e1b 2018-04-26) #43
phil-opp
added a commit
to phil-opp/linked-list-allocator
that referenced
this pull request
Apr 27, 2018
jlamb-at-polysync
referenced this pull request
Apr 30, 2018
Closed
Add out-of-memory language item #1
badboy
referenced this pull request
May 17, 2018
Merged
Update syn and quote, and offload options parsing to darling #120
japaric
referenced this pull request
Jun 20, 2018
Closed
undefined reference to 'rust_begin_unwind': {start,end}-group missing when using an allocator #51647
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
sfackler commentedApr 21, 2018
The decision of what to do after an allocation fails is orthogonal to the decision of how to allocate the memory, so this PR splits them apart.
Alloc::oomandGlobalAlloc::oomhave been removed, and a lang item has been added:It is specifically a weak lang item, like panic_fmt, except that it is required when you depend on liballoc rather than libcore. libstd provides an implementation that aborts with the message
fatal runtime error: memory allocation failed, matching the current behavior.The new implementation is also significantly simpler - it's "just another weak lang item". RFC 2070 specifies a path towards stabilizing panic_fmt, so any complexities around stable weak lang item definition are already being solved.
To bootstrap, oom silently aborts in stage0. alloc_system no longer has a bunch of code to print to stderr, and alloc_jemalloc no longer depends on alloc_system to pull in that code.
One fun note: System's GlobalAlloc implementation didn't override the default implementation of oom, so it currently aborts silently!
r? @alexcrichton