`<memory_resource>`: Conformance issues on `monotonic_buffer_resource::do_allocate`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
I find 2 conformance issues in the current implementation of monotonic_buffer_resource::do_allocate.
First, it does not meet to the requirement of [mem.res.monotonic.buffer.mem]/6.
This can have observable behavior differences if the upstream resource throws type of some derived bad_alloc on failure, which is not the exception throw by the call to _Xbad_alloc in monotonic_buffer_resource::_Increase_capacity.
This can be fixed by calling to the allocation function of the upstream resource with sufficient large size and alignment (so it is expected to fail).
Second, it fails to meet the allocation function requirement (implied by [mem.res.private]/2) for zero sizes when called more than once.
This can be fixed by changing the size to 1 before the call to std::align.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading monotonic_buffer_resource::do_allocate and its _Increase_capacity path, then compare both allocation cases with the linked standard requirements. Done means the upstream failure preserves the required exception behavior and repeated zero-size allocations meet the allocation-function requirement; validate these cases with the relevant existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100