Repository navigation
fix(libc): return posix_memalign allocation errors - #973
Conversation
|
Thanks. Returning the registered allocator's own error code, and EINVAL for an invalid alignment, matches POSIX and the One point on the Also, did a title hit this, or did you find it by reading the code? If a title's allocator returns ENOMEM here, please name it. |
|
Independent Linux verification (you listed Linux execution as unverified). Ubuntu 24.04, x86-64 (linux/amd64 container), GCC 13, CMake + Ninja, Release with
So the regression reproduces on Linux, not only Windows, and the fix makes the allocation error come back as |
0412065 to
c6dde16
Compare
|
@oneandonlydean Fixed in c6dde160. I removed the outer I added a regression for that exact case: before the correction it returned 12; after it, the test catches precisely This was found through source inspection and synthetic fixtures. No title hit it, and I have no title whose allocator returned ENOMEM to name. @011010 Thanks for independently verifying the earlier implementation on Linux, including the ENOMEM failure with main's production sources substituted and the two positive controls. I've linked your report in the description and kept it separate from my final-head Windows validation; I have not executed this revised head on Linux. The overlap with #313 is shared test context for its distinct C++ nothrow-allocation change; there is no semantic dependency. The updated PR is ready for another look. AI assistance: Codex, including this correction and regression. |
What
When a registered allocator returns ENOMEM,
posix_memaligncurrently throws instead of returning that status. Forward the callback's nonzero error code, keep the caller output unchanged on failure, return EINVAL for invalid alignment/output, and preserve errno on returned statuses. Successful allocations still pass the existing non-null and alignment checks.As requested in review, there is no outer
bad_alloccatch: the default allocator already converts allocation failure to ENOMEM. A registered allocator returning success with a null pointer violates its contract and still throwsstd::bad_alloc. A regression now checks that distinction and unchanged caller output.Found through source inspection and synthetic fixtures; no title encountered or reproduced this. The return-code contract is described by POSIX and FreeBSD. This improves the existing libc allocation capability in README Status. Measured badge impact is zero: libraries: 2504/2861 -> 2504/2861, shaders: 1135/1166 -> 1135/1166.
No observed competing POSIX callback-status correction as of 2026-10-06T23:50:59.765879+00:00; reviewed all 184 open PRs and 29 issues plus relevant diffs/discussions. #313 adds C++ nothrow allocation and shares a mechanically conflicting test hunk; it has no semantic dependency on this change. #1001 changes heap-finalization order. #639, #864, #887 and #968 change other functions. Depends on: none.
Tested
Windows 11 26200, MinGW-w64 GCC 15.2.0, CMake 4.4.4, Ninja 1.13.2, Release with BUILD_TESTING and SPIRV-Tools. All build targets and patched
libsbuilt. No game, firmware or console execution.ab9437e34df49c00b32a514a2516e15bd75145db; validated clean head:c6dde16023464136ee84a9a703671bc51e274bf8.ApplicationHeap.cpptest source:application_heap_replacementfails because ENOMEM 12 becomes an exception. Other heap controls and the new review case pass on the final head.std::bad_alloc.artifacts/AnyPS5/20261006T234533917Z-357747,artifacts/AnyPS5/20261006T234548143Z-40d83b,artifacts/AnyPS5/20261006T234600394Z-d6e9a0in the local workspace.pipelines/environment.ps1;pipelines/invoke.ps1 -Project AnyPS5 -BuildName AnyPS5-five-prs -Action Build -Jobs 8;-Action Test -TestRegex '^application_heap'; then-Action Testwithout a filter. Baseline:-SourcePath artifacts/AnyPS5/review-followup/base -BuildName AnyPS5-posix-review-base -Action Validate -TestRegex '^application_heap_replacement$' -Jobs 8, using the same pinned cached FFmpeg package.cmake --build build --parallel 8;cmake --build build --target libs --parallel 8;ctest --test-dir build --output-on-failure --timeout 120 -R '^application_heap'; repeat CTest without-Rfor Full.pipelines/contribution.py check artifacts/AnyPS5/review-followup/contribution.jsonpassed before pushing. Workspace tools and reports are excluded from the PR.011010 independently reported Linux heap checks on the earlier implementation, including reproducing the ENOMEM exception with main's production sources substituted. That report does not validate this revised head; I have not executed it on Linux.
Checklist
main; no observed competing implementation of this behavior