new_array<int>(LONG_MAX) does not raise exception
Issue #59
resolved
I tried to write a simple alloc test and raise std::bad_alloc exception. Something like this:
global_ptr<int> iptr = new_array<int>(LONG_MAX);
It did not raise exception and something actually got allocated. I tried to follow the code and it seems that this code in allocate.hpp:103 does not take into account that overflow might happen:
100 std::size_t size = sizeof(std::size_t);
101 size = (size + alignof(T)-1) & -alignof(T);
102 std::size_t offset = size;
103 size += n * sizeof(T);
I know that this is a cornet case.
And BTW if I do LONG_MAX-1024 I get some UPCXX assertion error.
Is there a way to extract GASNET shared memory size? Or I'll need to limit the size and play around it.
Comments (6)
-
reporter -
-
assigned issue to
-
assigned issue to
-
I fixed the first issue in 778ff6b. The second issue is an assert in
src/backend/gasnet/runtime.cpp
:UPCXX_ASSERT(p != nullptr);
I'm going to defer that one to John, as I don't know the intent behind it.
-
- assigned issue to
-
Account Deleted - changed status to resolved
Fixed issue 59
→ <<cset 4dc6b1468f82>>
-
-
assigned issue to
-
assigned issue to
- Log in to comment
I tried to allocate by using new_array() in the loop. It looks like I am running into some kind of assertion after allocating 128Mb. But no "bad_alloc" exception OR nullptr.
Here is the code that expects nullptr:
It get the following: