Uh oh!
There was an error while loading. Please reload this page.
Stabilize GlobalAlloc and #[global_allocator] - #51241
Conversation
rust-highfive
commented
May 31, 2018
r? @aidanhs (rust_highfive has picked a reviewer for you, use r? to override) |
glandium
commented
May 31, 2018
Cc: @SimonSapin |
SimonSapin
commented
May 31, 2018
Oh, I have pretty much the same branch and was only waiting to add docs before I submit it… :) |
glandium
commented
May 31, 2018
I wanted to see how that would impact me, so I went ahead but didn't bother with the doc. :) |
rust-highfive
commented
May 31, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
56439b4 to
dccf003Comparerust-highfive
commented
May 31, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
SimonSapin
commented
May 31, 2018
I’ve pushed additional commits to this PR. @glandium’s commits look good to me, mine still need review. In particular for the new docs and the API contracts they describe. Both tracking issues for features being stabilized have already finished FCP, but since we’re making last minute changes let’s have a final Final Comment Perdiod: @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
There was a problem hiding this comment.
This is used in the Alloc trait and therefore needs to be in libcore.
There was a problem hiding this comment.
Indeed. Removed that comment.
There was a problem hiding this comment.
This could probably be moved to liballoc since it is only used by collections.
There was a problem hiding this comment.
I moved it when I created the core::alloc module because it doesn’t depend on anything else, but with "collections" in the name maybe it belongs more where collections are define. I’ll leave this to whenever those APIs are stabilized.
There was a problem hiding this comment.
Does the concept of dropping an instance of GlobalAlloc really make sense? Should we just require pointers to be valid forever until explicitly freed?
There was a problem hiding this comment.
Good point, a static is never dropped. I copied this from Alloc docs but it doesn’t make sense here, removed.
rust-highfive
commented
May 31, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
| /// library that aborts on memory exhaustion.) | ||
| /// | ||
| /// Clients wishing to abort computation in response to an | ||
| /// allocation error are encouraged to call the [`oom`] function, |
There was a problem hiding this comment.
I hoped it would, but it doesn’t when the target is not in the source crate (or its dependencies?). Will fix.
| /// or NULL to indicate reallocation failure. | ||
| /// If this returns a non-null pointer, then ownership of the memory block | ||
| /// referenced by `ptr` has been transferred to this alloctor. | ||
| /// The memory may or may not have been deallocated, |
There was a problem hiding this comment.
In what situation would the memory not be deallocated?
There was a problem hiding this comment.
I’m not sure, I copied this form Alloc::realloc docs. Maybe when realloc succeeds in place and returns the same pointer? Would you rather I remove that sentence?
There was a problem hiding this comment.
ownership of the memory block referenced by
ptrhas been transferred to this alloctor.
There's a typo on allocator. I'd add a "back" after transferred, too, to make it subtly clearer that ownership of the memory block started from this allocator.
SimonSapin
commented
Jun 11, 2018
@bors r=sfackler,SimonSapin |
bors
commented
Jun 11, 2018
📌 Commit 7f0d54d has been approved by |
bors
commented
Jun 12, 2018
Stabilize GlobalAlloc and #[global_allocator] This PR implements the changes discussed in #49668 (comment)Fixes#49668Fixes#27389 This does not change the default global allocator: #36963
bors
commented
Jun 12, 2018
☀️ Test successful - status-appveyor, status-travis |
glandium
commented
Jun 13, 2018
Now that docs are up-to-date on https://doc.rust-lang.org/nightly/std/alloc/index.html, it feels like the docs for the reexports should be "inlined" (e.g. |
Bug 1458161 added a rust OOM handler based on an unstable API that was removed in 1.27, replaced with something that didn't allow to get the failed allocation size. Latest 1.28 nightly (2018-06-13) has rust-lang/rust#50880, rust-lang/rust#51264 and rust-lang/rust#51241 merged, which allow to hook the OOM handler and get the failed allocation size again. Because this is still an unstable API, we explicitly depend on strict versions of rustc. We also explicitly error out if automation builds end up using a rustc version that doesn't allow us to get the allocation size for rust OOM, because we don't want that to happen without knowing. --HG-- extra : rebase_source : 6c097151046d088cf51f4755dd69bde97bb8bd8b
SimonSapin
commented
Jun 14, 2018
SimonSapin
commented
Jun 17, 2018
Prohibit `global_allocator` in submodules Background: #44113 is caused by weird interactions with hygiene. Hygiene is hard. After a lot of playing around, we decided that the best path forward would be to prohibit `global_allocator`s from being in submodules for now. When somebody gets it working, we can re-enable it. This PR contains the following - Some hygiene "fixes" -- things I suspect are the correct thing to do that will make life easier in the future. This includes using call_site hygiene for the generated module and passing the correct crate name to the expansion config. - Comments and minor formatting fixes - Some debugging code - Code to prohibit `global_allocator` in submodules - Test checking that the proper error occurs. cc #44113#49320#51241 r? @alexcrichton
Add tracking issue for Layout methods (and some API changes) These methods are already useful when used with the stable global allocator API (stabilized in #51241). ```rust pub fn align_to(&self, align: usize) -> Result<Layout, LayoutErr>; pub fn padding_needed_for(&self, align: usize) -> usize; pub fn repeat(&self, n: usize) -> Result<(Layout, usize), LayoutErr>; pub fn extend(&self, next: Layout) -> Result<(Layout, usize), LayoutErr>; pub fn repeat_packed(&self, n: usize) -> Result<Layout, LayoutErr>; pub fn extend_packed(&self, next: Layout) -> Result<Layout, LayoutErr>; pub fn array<T>(n: usize) -> Result<Layout, LayoutErr>; ``` cc #32838 r? @SimonSapin
Bug 1458161 added a rust OOM handler based on an unstable API that was removed in 1.27, replaced with something that didn't allow to get the failed allocation size. Latest 1.28 nightly (2018-06-13) has rust-lang/rust#50880, rust-lang/rust#51264 and rust-lang/rust#51241 merged, which allow to hook the OOM handler and get the failed allocation size again. Because this is still an unstable API, we explicitly depend on strict versions of rustc. We also explicitly error out if automation builds end up using a rustc version that doesn't allow us to get the allocation size for rust OOM, because we don't want that to happen without knowing. UltraBlame original commit: 5182bca90d0609f182d5a7b6b48ed2ffbbce32c2
Bug 1458161 added a rust OOM handler based on an unstable API that was removed in 1.27, replaced with something that didn't allow to get the failed allocation size. Latest 1.28 nightly (2018-06-13) has rust-lang/rust#50880, rust-lang/rust#51264 and rust-lang/rust#51241 merged, which allow to hook the OOM handler and get the failed allocation size again. Because this is still an unstable API, we explicitly depend on strict versions of rustc. We also explicitly error out if automation builds end up using a rustc version that doesn't allow us to get the allocation size for rust OOM, because we don't want that to happen without knowing. UltraBlame original commit: 5182bca90d0609f182d5a7b6b48ed2ffbbce32c2
Bug 1458161 added a rust OOM handler based on an unstable API that was removed in 1.27, replaced with something that didn't allow to get the failed allocation size. Latest 1.28 nightly (2018-06-13) has rust-lang/rust#50880, rust-lang/rust#51264 and rust-lang/rust#51241 merged, which allow to hook the OOM handler and get the failed allocation size again. Because this is still an unstable API, we explicitly depend on strict versions of rustc. We also explicitly error out if automation builds end up using a rustc version that doesn't allow us to get the allocation size for rust OOM, because we don't want that to happen without knowing. UltraBlame original commit: 5182bca90d0609f182d5a7b6b48ed2ffbbce32c2
This PR implements the changes discussed in #49668 (comment)
Fixes#49668
Fixes#27389
This does not change the default global allocator: #36963