Skip to content

IRGen: don't stack promote classes for which the layout has not a fixed size #74969

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

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jul 4, 2024

In most cases this was already checked with ClassLayout::isFixedLayout. But for classes which are imported from another module and contain implementation-only C-imported stored properties, those properties don't show up in the class layout. Stack promoting such classes will reserve too less space on the stack which leads to all kind of memory corruption problems. The fix is to also check ClassLayout::isFixedSize, which returns false for such classes.

Fixes a miscompile
rdar://131067105
(duckdb/duckdb#11289)

…ed size

In most cases this was already checked with `ClassLayout::isFixedLayout`. But for classes which are imported from another module and contain implementation-only C-imported stored properties, those properties don't show up in the class layout. Stack promoting such classes will reserve too less space on the stack which leads to all kind of memory corruption problems. The fix is to also check `ClassLayout::isFixedSize`, which returns false for such classes.

Fixes a miscompile
rdar://131067105
@eeckstein eeckstein requested a review from rjmccall as a code owner July 4, 2024 15:04
@eeckstein eeckstein requested review from aschwaighofer and removed request for rjmccall July 4, 2024 15:04
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit 9580b21 into swiftlang:main Jul 5, 2024
5 checks passed
@eeckstein eeckstein deleted the fix-stack-promotion branch July 5, 2024 06:54
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.

1 participant