Repository navigation
Free over-aligned array new storage correctly on exception (non-IA-64) [GH #552] - #565
lexx42xxel wants to merge 2 commits into
Conversation
…) [GH edgcpp#552] With the non-IA-64 ABI, new[] of an over-aligned type uses the alignment as the size of the prefix, but the cleanup for a throwing brace or list initialization freed p - __array_new_prefix_size: a bad free and a leak. Pass the actual prefix size to the cleanup. 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. |
Following review feedback on a related pull request, do not start the argument list of the make_reusable_copy call on a new line; break the assignment after the "=" instead, as elsewhere in lower_init.c. No functional change.
|
AcknowlEDG review results updated for
CI success. |
Fixes the problem reported in triage discussion #552.
Problem and fix
With the non-IA-64 ABI, new[] of an over-aligned type uses the alignment
as the size of the prefix, but the cleanup for a throwing brace or list
initialization freed p - __array_new_prefix_size: a bad free and a leak.
Pass the actual prefix size to the cleanup.
Alternatives considered
Compute the prefix inside the runtime cleanup. Rejected: the runtime does not know the alignment; passing the prefix size the front end already used keeps allocation and deallocation consistent.
Tests
New:
tests/tests/regressions/array-new-aligned-throw-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
bad-freeon main; no report with the fix or with g++.Checklist
Commits are tagged
[GH #552]with the discussion number; happy to retag once an issue is opened.[GH #552].src/pending_changes/gh-552-noia64-aligned-array-new-eh.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
new. Storage is now released using the correct allocation pointer, including for brace- and list-initialized arrays.