-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0-length arrays in Buddy ranges (#672)
* backend_helpers: introduce NopRange * Fix to Buddy MIN == MAX case This fixes the 0-length arrays discussed (and made into assertion failures) in the next commit. This works because the Buddy's `MIN_SIZE_BITS` is instantiated at `MIN_CHUNK_BITS`, and so we ensure that we instantiate the LargeBuddyRange only with `max_page_chunk_size_bits` above `MIN_CHUNK_BITS`. * Buddy range: assert that MAX > MIN Now that the case leading to several 0-sized arrays in Buddy ranges, that then cause gcc's -Warray-bounds to trip, has been removed, add a static assert so that we can catch this with better error messages next time.
- Loading branch information
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include "range_helpers.h" | ||
|
||
namespace snmalloc | ||
{ | ||
struct NopRange | ||
{ | ||
template<typename ParentRange> | ||
class Type : public ContainsParent<ParentRange> | ||
{ | ||
using ContainsParent<ParentRange>::parent; | ||
|
||
public: | ||
static constexpr bool Aligned = ParentRange::Aligned; | ||
|
||
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe; | ||
|
||
using ChunkBounds = typename ParentRange::ChunkBounds; | ||
static_assert( | ||
ChunkBounds::address_space_control == | ||
capptr::dimension::AddressSpaceControl::Full); | ||
|
||
constexpr Type() = default; | ||
|
||
CapPtr<void, ChunkBounds> alloc_range(size_t size) | ||
{ | ||
return parent.alloc_range(size); | ||
} | ||
|
||
void dealloc_range(CapPtr<void, ChunkBounds> base, size_t size) | ||
{ | ||
parent.dealloc_range(base, size); | ||
} | ||
}; | ||
}; | ||
} // namespace snmalloc |