-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implement #[alloc_error_handler] #52191
Conversation
…h ABI of the declaration in liballoc This turned out to be important on Windows. Calling `handle_alloc_error(Layout::new::<[u8; 42]>())` caused: ``` Exception thrown at 0x00007FF7C70DC399 in a.exe: 0xC0000005: Access violation reading location 0x000000000000002A. ``` 0x2A equals 42, so it looks like the `Layout::size` field of type `usize` was interpreted as a pointer to read from.
This to-be-stable attribute is equivalent to `#[lang = "oom"]`. It is required when using the alloc crate without the std crate. It is called by `handle_alloc_error`, which is in turned called by "infallible" allocations APIs such as `Vec::push`.
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
Kudos to @ollie27 for catching the ABI mismatch (fixed in the first commit) #52110 (comment). This turned out to be the reason why the new test (now second commit) failed on Windows at #52110 (comment). Calling
0x2A equals 42, so it looks like the |
@bors: r+ |
📌 Commit 239ec7d has been approved by |
⌛ Testing commit 239ec7d with merge 08fe845e78253595c097779dfc5b8f20e007dc6d... |
💔 Test failed - status-appveyor |
@bors retry |
Implement #[alloc_error_handler] This to-be-stable attribute is equivalent to `#[lang = "oom"]`. It is required when using the `alloc` crate without the `std` crate. It is called by `handle_alloc_error`, which is in turned called by "infallible" allocations APIs such as `Vec::push`.
☀️ Test successful - status-appveyor, status-travis |
This to-be-stable attribute is equivalent to
#[lang = "oom"]
. It is required when using thealloc
crate without thestd
crate. It is called byhandle_alloc_error
, which is in turned called by "infallible" allocations APIs such asVec::push
.