-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Support custom allocators in Box
#77187
Conversation
@nikomatsakis wrote in #71873 (comment)
What is the state of this? |
No change. But I'll be sure to bring this up in the wg-traits meeting on tuesday. |
That would be great, thank you! |
c0e060b
to
39bf29f
Compare
Rebased onto master to include #77118 |
where | ||
T: 'a, // Technically not needed, but kept to be explicit. | ||
A: 'a, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test, which ensures, that the allocator must not be moved while the leaked data is in use.
Just wanted to check in to say we did talk about this today at our @rust-lang/wg-traits meeting. We worked out a design that we're hoping to get into Chalk by next release on Saturday. Then it'll just be a Chalk upgrade and this should be unblocked from that. |
That's awesome, thank you! |
Rebased onto master to include #77289 |
44cfe3d
to
db359a0
Compare
☔ The latest upstream changes (presumably #77436) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
☔ The latest upstream changes (presumably #77466) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Remove `Box::leak_with_alloc` Add leak-test for box with allocator Rename `AllocErr` to `AllocError` in leak-test Add `Box::alloc` and adjust examples to use the new API
Tested on commit rust-lang/rust@fd54259. Direct link to PR: <rust-lang/rust#77187> 💔 miri on windows: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung). 💔 miri on linux: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung).
|
||
// The box is unitiliazed later when moving out the allocator. The pointer is stored | ||
// beforehand. | ||
let ptr = b.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this code broke Stacked Borrows. The code before was very careful to go through a mutable reference, as the comment explains. That comment was retained but the mutable reference is no longer used, so this code no longer works.
I'll submit a PR to fix this. In the future, when you find comments like this and are not sure what to do about them, feel free to ping me. :)
test Box::into_raw aliasing Directly test aliasing problems caused by `Box::into_raw` issues (like we have them again right now due to rust-lang/rust#77187, but the pinned rustc is older than that so this should still be able to land).
test Box::into_raw aliasing Directly test aliasing problems caused by `Box::into_raw` issues (like we have them again right now due to rust-lang/rust#77187, but the pinned rustc is older than that so this should still be able to land).
test Box::into_raw aliasing Directly test aliasing problems caused by `Box::into_raw` issues (like we have them again right now due to rust-lang/rust#77187, but the pinned rustc is older than that so this should still be able to land).
fix Box::into_unique rust-lang#77187 broke Stacked Borrows pointer tagging around `Box::into_unique` (this is caused by `Box` being a special case in the type system, which box-internal code needs to account for). This PR fixes that. r? `@Amanieu` Cc `@TimDiekmann` Fixes rust-lang#78419.
I would also like to raise awareness about the issue of this breaking ABI here, more in my comment over at the related PR for |
Is there a write-up available on this design? I've been reading through the custom allocator PRs, and don't have a good sense why for example #58457 was abandoned in favor of the current design. The designs appear to differ, and I'd like to better understand why that choice was made. edit: I guess the right place to ask would be in #32838 which tracks this work. I didn't see the issue linked from here, so I missed it. Apologies! edit: The allocator WG appears to be tracking the methods introduced in this PR here: rust-lang/wg-allocators#7. This is the exact resource I was looking for. |
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
FWIW this PR caused a lot of pain in the compiler, a long stream of ICEs, accidental UB -- altogether causing a lot of work for a lot of people. See #95453 for more details. This should never have landed without a discussion with the compiler team on how to support |
r? @Amanieu
This pull request requires a crater run.
Prior work:
alloc-wg
-crateCurrently blocked on:
Stability annotations on generic parameters (take 2.5) #77118Implement clauses to allow multi-parameter fundamental types chalk#615 (Update to chalk 0.31 #77515)