Skip to content

[6.2][Distributed] fix distributed thunk method descriptor mangling in IRGen #81831

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 2 commits into
base: release/6.2
Choose a base branch
from

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented May 29, 2025

Description: While we mangle distributed thunks correctly in Mangler we did not update IRGenMangler to also handle them. This remained undiscovered until developers needed to use library evolution where these method descriptors are used, and the distributed_thunk descriptors would be mangled the same as the not-thunks, leading to duplicate symbols. This would result in .N suffixes and break the manled names in resilient witness tables.

Finally, this would manifest in runtime not being able to obtain a witness from the resilient witness table when library evolution is enabled, and causing null witnesses and crashes at runtime when attempting to make remote calls in such project.

This corrects the missing mangling part, which then corrects everything else implicitly -- since we no longer have duplicated symbols, and the thunks are uniqued correctly, everything falls into place and works well.

Scope/Impact: Distributed actors adopters which use library evolution. Specifically, attempts to make a remote call on a https://github.com/resolvable protocol would crash without this fix, making https://github.com/resolvable and the "server / client split" approach of distributed actors not usable at all with library evolution.

Risk: Low, the fix is very centralized to distributed thunks and sil witness tables of distributed protocol witnessing actors.

Testing: Added test verifying the emitted witness tables. Confirmed in real project hitting this problem that the solution is correct and resolves the crashes.
Reviewed by: @xedin

Original PR: #81805
Radar: rdar://144568615

@ktoso ktoso requested a review from a team as a code owner May 29, 2025 10:19
@ktoso ktoso requested review from xedin and hborla May 29, 2025 10:20
@ktoso ktoso added distributed Feature → concurrency: distributed actor 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels May 29, 2025
@ktoso
Copy link
Contributor Author

ktoso commented May 29, 2025

@swift-ci please test

@ktoso ktoso changed the title Pick irgen mangling fix distributed [6.2][Distributed] fix distributed thunk method descriptor mangling in IRGen May 29, 2025
@ktoso ktoso requested a review from DougGregor May 29, 2025 22:53
@@ -86,6 +86,8 @@ class IRGenMangler : public Mangle::ASTMangler {
beginMangling();
appendEntity(func);
appendOperator("Tq");
if (func->isDistributedThunk())
appendSymbolKind(SymbolKind::DistributedThunk);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"the fix"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant