Skip to content

[6.2][Runtime] Allow weak references to ErrorObjects. #81616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/6.2
Choose a base branch
from

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented May 19, 2025

Cherry-pick #81562 to release/6.2.

When ObjC interop is not available, Error values are represented in ErrorObject boxes. These are full HeapObjects, but unowned refcounting ops asserted that the metadata was class metadata. This assert would be hit when destroying an ErrorObject that was weakly referenced. Expand the asserts to accept ErrorObject metadata as well.

rdar://150214921

When ObjC interop is not available, Error values are represented in ErrorObject boxes. These are full HeapObjects, but unowned refcounting ops asserted that the metadata was class metadata. This assert would be hit when destroying an ErrorObject that was weakly referenced. Expand the asserts to accept ErrorObject metadata as well.

rdar://150214921
(cherry picked from commit aea9c0c)
@mikeash mikeash requested a review from a team as a code owner May 19, 2025 19:22
@mikeash
Copy link
Contributor Author

mikeash commented May 19, 2025

Explanation: Weak references to Error boxes produce an incorrect assertion failure.
Scope: Affects Swift Testing's error backtrace tracking code on non-Darwin platforms. (Darwin uses NSError objects rather than Error boxes so this isn't an issue there.)
Issue: rdar://150214921
Risk: Very low. The only change is to relax a set of asserts in the runtime.
Testing: Added a test for weak references to Error boxes. Existing tests have good coverage of the code in question otherwise.
Reviewer: @al45tair

@mikeash
Copy link
Contributor Author

mikeash commented May 19, 2025

@swift-ci please test

@mikeash mikeash enabled auto-merge May 19, 2025 20:31
@mikeash
Copy link
Contributor Author

mikeash commented May 20, 2025

@swift-ci please test macos platform

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.

2 participants