-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] Enforce strict order of synthesized id and actorSystem properties; avoid wrong offset crashes #58745
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
// important. The `hint` below makes sure the system is inserted right after. | ||
auto id = derived.Nominal->getDistributedActorIDProperty(); | ||
derived.addMemberToConformanceContext(pbDecl, /*hint=*/id); | ||
derived.addMemberToConformanceContext(propDecl, /*hint=*/id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures the system is always AFTER the ID
llvm_unreachable("DistributedActor.id MUST be synthesized earlier, " | ||
"because it is forced by the Identifiable conformance. " | ||
"If we attempted to do synthesis here, the earlier phase " | ||
"failed and something is wrong: please report a bug."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had to move away from its synthesis here a while back so this was dead code;
Actually I should just delete the hangling here I guess.
@@ -27,33 +26,25 @@ import WinSDK | |||
/// for learning about `distributed actor` isolation, as well as early | |||
/// prototyping stages of development where a real system is not necessary yet. | |||
@available(SwiftStdlib 5.7, *) | |||
public struct LocalTestingDistributedActorSystem: DistributedActorSystem, @unchecked Sendable { | |||
public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @unchecked Sendable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This UNDOES the workaround (which actually did not work after all).
This is NOT a change in the API of the system
@@ -286,7 +274,7 @@ func test() async { | |||
|
|||
let localDA = LocalTestingDA_Int() | |||
print("localDA = \(localDA.id)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would have crashed recently -- this patch fixes it.
@swift-ci please test |
Note that even the 32 bit watch passed here... and does not on 5.7, so we're missing something there 🤔
|
Resolves rdar://92712849 - the root cause of all those issues
Resolves rdar://92910719 - which disabled the still failing test since the workaround was not good enough
This is the actual solution for all our mystical offset issues -- the order of the synthesized AST fields MUST match the order IRGen enforces (and the DA needs in any case); where the id and system are the FIRST fields, and must be specifically: id, system because that's what IRGen emits and many places seem to expect the order matches between the original AST and whatever gets derived form it and IR.
This probably also resolves a few other crashers we had with similar crash reasons of weird mismatching offsets, I'll be verifying those.