Skip to content

[6.1] Fix the demangling of sending result types when combined with isolation #78641

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

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Jan 14, 2025

When the symbol mangler mangles a function type, it adds operators representing different aspects of the type in a specific order. The demangler accumulates these operators on a stack, then needs to pop them off in the exact reverse of that order. Unfortunately, the demangler was trying to pop one operator (representing that the result type is sending) in the wrong order, causing it to fail to demangle names that combined that operator with certain other operators (representing function isolation, such as a global actor attribute).

In assertion builds of the compiler, we verify that we can demangle every symbol we mangle, and declarations that featured a type such as @MainActor () -> sending T would trip the assertion. With assertions disabled, we would successfully mangle such symbols. As a result, we cannot reasonably change the mangling order to match the current demangler and must instead change the demangler to expect operators in the right order. This is somewhat unfortunate because the demangler is partially a runtime component (as is the mangler, although this code path is not heavily used).

This patch fixes the demangler to expect the operators in the right order. This will cause assertions builds of the compiler to go back to successfully building code that combines these features, and it will allow newly-built runtimes to successfully demangle such types. We will need a follow-up compiler patch to fix the compiler to not attempt to exercise the runtime's ability to demangle such types on existing runtimes (which just means the 6.0 runtime).

Scope: affects all demangle paths on a combination of features that's somewhat uncommon
Risk: low
Testing: added new demangling tests
Issue: rdar://142443925
Reviewer: @gottesmm
Original PR: #78576.

Fixes the immediate problem, but the presence of demangling code in the
runtime means that we'll need a follow-up to fix the compiler so that it
doesn't try to use the demangler to materialize metadata for function types
that have both isolation and a sending result.

rdar://142443925
@rjmccall rjmccall requested a review from a team as a code owner January 14, 2025 23:19
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall merged commit 714ecbd into swiftlang:release/6.1 Jan 15, 2025
5 checks passed
@rjmccall rjmccall deleted the demangle-sending-result-with-function-isolation-6.1 branch January 15, 2025 18:31
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.

3 participants