Skip to content

stdlib: add a missing fixLifetime in withVaList #79056

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

Closed
wants to merge 1 commit into from

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Jan 30, 2025

If this function is inlined, the optimizer can shrink the lifetime of the args parameter. This would deallocate the passed arguments (e.g. NSStrings) before the are used in the closure.

This problem showed up in the TestNSString.test_initializeWithFormat4 swift-corelibs-foundation test (on linux) when enabling OSSA modules (#78939)

If this function is inlined, the optimizer can shrink the lifetime of the `args` parameter. This would deallocate the passed arguments (e.g. `NSString`s) before the are used in the closure.
@eeckstein eeckstein requested a review from a team as a code owner January 30, 2025 18:54
@eeckstein eeckstein requested a review from meg-gupta January 30, 2025 18:55
@eeckstein
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Commentary: we need to enable lexical lifetimes in the stdlib for some important reasons such as

- avoiding bugs like this
- recurring bugs where devs copy code between the Swift module and other tests modules and expect consistent behavior

As Meghana explained, this is an array value without a lexical lifetime. And I don't think it matters how we build the stdlib given that @inlinable is required.

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test windows

@eeckstein
Copy link
Contributor Author

This commit is already included in #78939

@eeckstein eeckstein closed this Jan 31, 2025
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.

4 participants