Skip to content

Conversation

@eeckstein
Copy link
Contributor

When an owned value has no lifetime ending uses it means that it is in a dead-end region.
We must not remove and inserting compensating destroys for it because that would potentially destroy the value too early.
Initialization of an object might be cut off and removed after a dead-end loop or an unreachable.
In this case a class destructor would see uninitialized fields.

Also fix the same problem in SILCombine for dead Array.adoptStorage calls.

Fixes a mis-compile
#85851
rdar://165876726

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci apple silicon benchmark

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test windows

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@aidan-hall aidan-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

If followed by a dead infinite loop, the array initialization might have beed removed.
Therefore when inserting a compensating destroy of the array buffer can lead to a crash.

swiftlang#85851
rdar://165876726
…-end blocks

When an owned value has no lifetime ending uses it means that it is in a dead-end region.
We must not remove and inserting compensating destroys for it because that would potentially destroy the value too early.
Initialization of an object might be cut off and removed after a dead-end loop or an `unreachable`.
In this case a class destructor would see uninitialized fields.

Fixes a mis-compile
swiftlang#85851
rdar://165876726
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein eeckstein enabled auto-merge December 5, 2025 16:09
@eeckstein eeckstein merged commit e987c92 into swiftlang:main Dec 5, 2025
3 checks passed
@eeckstein eeckstein deleted the fix-silcombine branch December 6, 2025 05:32
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