Skip to content

[Distributed] correct take semantics for synthesized ID assignments #63779

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 2 commits into from
Feb 21, 2023

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Feb 20, 2023

Resolves #62898
Resolves rdar://104583893

This is a surprising regression because it always was wrong, but only started failing in recent toolchains where this started getting verified.

I'll also wok on getting distributed cluster into the source compat build, which we didn't complete for some reason before: swiftlang/swift-source-compat-suite#730 which would have likely caught this when the toolchain changed to detect this wrong lifetime.

I also confirmed this works on the reproducer steps, targeting swift-distributed actors main and indeed this started failing but used to somehow sneakily still pass on older toolchains:

  • git clone https://github.com/apple/swift-distributed-actors.git
  • export SWIFT_EXEC=$HOME/code/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swiftc
    • on a build that has this fix
  • swift run --package-path Samples/Sources/SampleDiningPhilosophers
  • echo $SWIFT_EXEC; echo; echo; /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-02-18-a.xctoolchain/usr/bin/swift run --package-path Samples/Sources/SampleDiningPhilosophers

@ktoso
Copy link
Contributor Author

ktoso commented Feb 20, 2023

@swift-ci please smoke test

@ktoso ktoso force-pushed the wip-distributed-inits-sil-issue branch from 700bc18 to 7ecfc82 Compare February 20, 2023 13:48
}
someField = try getSomeClass()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds a test for a class based actor system which was a thing we didn't cover well, but in the real world most systems will be; This is the same as the other sil_n tests but for a class.

@@ -209,7 +209,7 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
{ temp, selfMetatypeValue });

// --- initialize the property.
initializeProperty(*this, loc, borrowedSelfArg, var, temp);
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 issue was here, so changing to take here is correct, but the other sites want to remain not-take.

Thanks @eeckstein and @drexin for the pointers !

@ktoso ktoso added the distributed Feature → concurrency: distributed actor label Feb 20, 2023
Copy link
Contributor

@drexin drexin left a comment

Choose a reason for hiding this comment

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

LGTM

@ktoso
Copy link
Contributor Author

ktoso commented Feb 20, 2023

@swift-ci please smoke test

///
/// By adding the `Any` we don't know the full size of the struct making the type in SIL `$*ActorAddress`
/// when we try to store or pass it around, which triggers `isAddressOnly` guarded paths which we need to test.
public struct NotLoadableActorAddress: Hashable, Sendable, Codable {
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 important bit to reproduce the issue

@ktoso ktoso force-pushed the wip-distributed-inits-sil-issue branch from b92995a to 629ac65 Compare February 21, 2023 05:21
@ktoso
Copy link
Contributor Author

ktoso commented Feb 21, 2023

Added another test that exercises the AddressOnly case as well.

@ktoso
Copy link
Contributor Author

ktoso commented Feb 21, 2023

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 12b5aa7 into main Feb 21, 2023
@swift-ci swift-ci deleted the wip-distributed-inits-sil-issue branch February 21, 2023 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"SIL memory lifetime failure" when attempting to build Distributed Actors example.
4 participants