Repository navigation
Fix sized delete size for zero-length array new [GH #550] - #563
lexx42xxel wants to merge 1 commit into
Conversation
array_new_general increased a zero-byte request to one byte even when there is an array cookie, but the placement, nothrow, and aligned paths and the IA-64 delete[] and exception cleanup compute n * size + prefix, so a sized operator delete[] received a different size for n == 0. Increase the size only when there is no prefix (as __cxa_vec_new2 and g++ do); the non-IA-64 get_array_size no longer adjusts it either. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
AcknowlEDG review results updated for
|
|
AcknowlEDG review results updated for
CI success. |
Fixes the problem reported in triage discussion #550.
Problem and fix
array_new_general increased a zero-byte request to one byte even when
there is an array cookie, but the placement, nothrow, and aligned paths
and the IA-64 delete[] and exception cleanup compute n * size + prefix, so
a sized operator delete[] received a different size for n == 0. Increase
the size only when there is no prefix (as __cxa_vec_new2 and g++ do); the
non-IA-64 get_array_size no longer adjusts it either.
Alternatives considered
Also bump the size in the delete[] and cleanup paths. Rejected: the allocated size would then differ from what
__cxa_vec_new2and g++ request, and every path that computesn * size + prefixwould need the same special case.Tests
New:
tests/tests/regressions/array-new-zero-length-sized-delete.sft.cpp.Verified failing on main and passing with the fix (IA-64 and non-IA-64 builds); reproducer in the discussion.
AddressSanitizer: the discussion's reproducer (ASan variant) reports
new-delete-type-mismatchon main; no report with the fix or with g++.Checklist
Commits are tagged
[GH #550]with the discussion number; happy to retag once an issue is opened.[GH #550].lib_src/pending_changes/gh-550-zero-length-array-new-sized-delete.txt.edg-docker-test --posture=extensive(edg_x86_64, edg_x86_64_cp, edg_x86_32, edg_x86_32_cp): no regressions; recordings updated with-W.Summary by CodeRabbit
Bug Fixes
Tests