Stream: t-libs/wg-allocators

Topic: global allocator fails to allocate isize::MAX


Tim Diekmann (Nov 21 2019 at 18:34, on Zulip):

I added the liballoc tests to alloc-wg in this PR. The function test_try_reserve fails as the global allocator is not able to allocate isize::MAX bytes. Does the compiler use another allocator for testing liballoc? Or do I oversee something?

Tim Diekmann (Nov 21 2019 at 18:36, on Zulip):

At the current commit, it panics at line 1132-1134

Tim Diekmann (Nov 21 2019 at 18:38, on Zulip):

Precisely It calls

#[stable(feature = "global_alloc", since = "1.28.0")]
#[inline]
pub unsafe fn alloc(layout: Layout) -> *mut u8 {
    __rust_alloc(layout.size(), layout.align())
}

with

core::alloc::Layout { size: 9223372036854775807, align: 1}

and returns NULL

Tim Diekmann (Nov 21 2019 at 18:39, on Zulip):

I double checked the number, it's isize::MAX: 7fffffffffffff...

Tim Diekmann (Nov 21 2019 at 18:44, on Zulip):

Nevermind, it's a result of AbortAlloc.

Tim Diekmann (Nov 21 2019 at 18:51, on Zulip):

I'll open a new topic regarding AbortAlloc in combination with try_reserve.

Erich Gubler (Nov 22 2019 at 00:30, on Zulip):

I don't understand the context behind this test. Why would they try to allocate so much as a test?

Mike Hommey (Nov 22 2019 at 00:33, on Zulip):

It's supposed to fail. Always. That's what is being tested.

Tim Diekmann (Nov 22 2019 at 04:23, on Zulip):

It must not fail with a CapacityOverflow. Interesting for 16/32 bit platforms

gnzlbg (Nov 28 2019 at 16:53, on Zulip):

@Tim Diekmann are you on Windows ?

gnzlbg (Nov 28 2019 at 16:54, on Zulip):

This test has no problems if you have a system with overcommit

gnzlbg (Nov 28 2019 at 16:54, on Zulip):

You might want to check on which OSes does libstd run this test

gnzlbg (Nov 28 2019 at 16:57, on Zulip):

e.g., I expect this test to "fail by not failing" on, e.g., x86_64-unknown-linux-gnu-x32

gnzlbg (Nov 28 2019 at 16:58, on Zulip):

where isize::MAX bytes is 4 Gbs, but that's a reasonable allocation on the target

gnzlbg (Nov 28 2019 at 16:59, on Zulip):

It must not fail with a CapacityOverflow. I

If by this you mean that this test must pass, and that this only happens if the try_reserve functions return CapacityOverflow, then that's correct - that's the intent of the test.

Last update: Dec 12 2019 at 00:50UTC