Skip to content

Reject allocation size overflow in memory resource adaptor - #2360

Merged
ericniebler merged 1 commit into
NVIDIA:mainfrom
darkdi:darkdi/check-memory-resource-size
Oct 26, 2026
Merged

ericniebler merged 1 commit into
NVIDIA:mainfrom
darkdi:darkdi/check-memory-resource-size

Conversation

@darkdi

@darkdi darkdi commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

allocate_bytes(SIZE_MAX, 16) with an adapted allocator wraps the bookkeeping size, then asserts in Debug or segfaults in Release. Reject the overflow with std::bad_alloc before calling the allocator. Boundary regressions, 1,062 CPU CTest cases, and clang-format 21 pass on macOS arm64, plus ASan/UBSan checks and a no-exceptions smoke test.

Signed-off-by: Dmitry Rantovov <rantovov5@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 3f658c2

@ispeters

Copy link
Copy Markdown
Contributor

@darkdi, I'm curious how you found this bug. You're fixing a problem in the reference implementation for P4223R1 so I'd be interested in any user experiences you have with exec::function.

@darkdi

darkdi commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Found during a Codex-assisted audit of allocation-size arithmetic. I checked allocate_bytes(SIZE_MAX, 16) with a custom allocator: the bookkeeping size wrapped, followed by an assertion in Debug and a segfault in Release. I haven't used exec::function in an application, so I don't have user experience to report there.

@darkdi

darkdi commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

I also checked the red sanitizer jobs. The same four configurations fail on merged #2359: clang 16 ASAN segfaults while listing test.scratch tests, and gcc 14 TSAN reports an incompatible memory layout/ASLR error during test discovery. This PR's logs show the same failures. Both GCC 14 ASAN configurations and the GPU matrix pass here.

@ericniebler
ericniebler merged commit 653aca1 into NVIDIA:main Oct 26, 2026
36 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants