Skip to content

[Distributed] Distributed thunks take parameters as 'sending' #74166

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 1 commit into from
Jun 6, 2024

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jun 6, 2024

This is in order to avoid errors in complete concurrency checking mnode in distributed funcs, or rather their thunks, as there is isolation boundary crossing happening when we pass a value to a distributed func.

This is because as we do this, we pass it to a nonisolated thunk:

nonisolated func THUNK(param: Thing) {
  if remote {
    ...
  } else {
    await self.realFunc(param)
  }
}

So what happens here is that the Thing would become isolated to the task and we get a bad isolation crossing as we pass it along to the "real func".

Sending values into the distributed thunk is the right thing to do to resolve this problem: nonisolated func THUNK(param: sending Thing) {}

ABI / Distributed func identifier safety: This is safe to change because the sending is not mangled in method parameters, as we cannot overload on it, so this change should not break remote calls between swift versions AFAICS.

Resolves rdar://126577527

This is in order to avoid errors in complete concurrency checking mnode
in distributed funcs, or rather their thunks, as there is isolation
boundary crossing happening when we pass a value to a distributed func.

This is because as we do this, we pass it to a nonisolated thunk:

```
nonisolated func THUNK(param: Thing) {
  if remote {
    ...
  } else {
    await self.realFunc(param)
  }
}
```

So what happens here is that the Thing would become isolated to the
task and we get a bad isolation crossing as we pass it along to the
"real func".

Sending values into the distributed thunk is the right thing to do to
resolve this problem: `nonisolated func THUNK(param: sending Thing) {}`

Resolves rdar://126577527
@ktoso ktoso requested a review from hborla as a code owner June 6, 2024 03:34
@ktoso ktoso requested review from DougGregor, xedin, gottesmm and hborla and removed request for hborla and DougGregor June 6, 2024 03:34
@ktoso
Copy link
Contributor Author

ktoso commented Jun 6, 2024

@swift-ci please smoke test

@ktoso ktoso merged commit d33011a into swiftlang:main Jun 6, 2024
3 checks passed
@ktoso ktoso deleted the wip-sending-distributed-thunk branch June 6, 2024 07:48
@ktoso ktoso added the distributed Feature → concurrency: distributed actor label Jun 6, 2024
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.

2 participants