Skip to content
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

[Distributed] Ensure to swift_release during destroying decoded distributed call arguments #65952

Merged
merged 2 commits into from
May 20, 2023

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented May 16, 2023

Follow up to #65874
Resolves: #65853 now also ensuring deinits properly run.

Thanks for review @DougGregor
Huge thanks to @xedin for helping debug the issue.

We must destroy before we deallocate, otherwise the destroy does nothing to refcount and we would not run deinitializers as expected.

@ktoso
Copy link
Contributor Author

ktoso commented May 16, 2023

@swift-ci please smoke test

@ktoso ktoso requested a review from xedin May 16, 2023 19:28
@xedin
Copy link
Contributor

xedin commented May 16, 2023

Why?

@ktoso ktoso force-pushed the wip-destroy-dist-args-reverse-order branch from b58b86e to 842771c Compare May 16, 2023 19:41
@ktoso
Copy link
Contributor Author

ktoso commented May 16, 2023

@DougGregor asked for it, I guess so it's the same as other things in this func, also in reverse? "Shouldn't matter but" I guess

@xedin
Copy link
Contributor

xedin commented May 16, 2023

The other thing is stack allocations which should be in reverse order, this one is just calls to destroy function that’s why I am asking the question here :)

@ktoso
Copy link
Contributor Author

ktoso commented May 16, 2023

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented May 16, 2023

Yeah it really shouldn't matter for this one... I'll ask @DougGregor if he thinks we'd better do it like this anyway or nah.

@ktoso
Copy link
Contributor Author

ktoso commented May 16, 2023

note to self; add some more tests to check various combinations of types

@ktoso ktoso force-pushed the wip-destroy-dist-args-reverse-order branch from 842771c to 73cd2c9 Compare May 17, 2023 10:14
@ktoso
Copy link
Contributor Author

ktoso commented May 17, 2023

I was adding more tests and actually see that deinits DON'T run and we have an unbalanced retain here still -- even if the memory is properly destroyed so we don't leak the object itself. We're in the Direct_Guaranteed case and take the param with loadAsTake so that's right... I don't know where else the bad retain could be from 🤔

@ktoso ktoso force-pushed the wip-destroy-dist-args-reverse-order branch from 73cd2c9 to 6649804 Compare May 19, 2023 21:19
@ktoso ktoso changed the title [Distributed] Destroy decoded remote call arguments in reverse order [Distributed] Ensure to swift_release during destroying decoded distributed call arguments May 19, 2023
@ktoso ktoso force-pushed the wip-destroy-dist-args-reverse-order branch from 6649804 to abdfb15 Compare May 19, 2023 21:21
@ktoso
Copy link
Contributor Author

ktoso commented May 19, 2023

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented May 19, 2023

@swift-ci please smoke test

lib/IRGen/GenDistributed.cpp Outdated Show resolved Hide resolved
@ktoso
Copy link
Contributor Author

ktoso commented May 19, 2023

Fixed formatting

@ktoso
Copy link
Contributor Author

ktoso commented May 19, 2023

@swift-ci please smoke test and merge

@ktoso ktoso added the distributed Feature → concurrency: distributed actor label May 19, 2023
@swift-ci swift-ci merged commit 222946b into swiftlang:main May 20, 2023
@ktoso ktoso deleted the wip-destroy-dist-args-reverse-order branch May 20, 2023 10:58
ktoso added a commit to ktoso/swift that referenced this pull request Jan 10, 2024
We recently fixed a similar issue where the objects created from
decodeNextArgument in a distributed thunk were not properly destroyed.
The fix was in swiftlang#65952

In that fix, we missed handling of Indirect_In_Guaranteed which also
need to be destroyed, this patch corrects that omission.

Resolves swiftlang#70004
Resolves rdar://119943672
Resolves rdar://119446012
ktoso added a commit to ktoso/swift that referenced this pull request Jan 10, 2024
We recently fixed a similar issue where the objects created from
decodeNextArgument in a distributed thunk were not properly destroyed.
The fix was in swiftlang#65952

In that fix, we missed handling of Indirect_In_Guaranteed which also
need to be destroyed, this patch corrects that omission.

Resolves swiftlang#70004
Resolves rdar://119943672
Resolves rdar://119446012
ktoso added a commit to ktoso/swift that referenced this pull request Jan 10, 2024
We recently fixed a similar issue where the objects created from
decodeNextArgument in a distributed thunk were not properly destroyed.
The fix was in swiftlang#65952

In that fix, we missed handling of Indirect_In_Guaranteed which also
need to be destroyed, this patch corrects that omission.

Resolves swiftlang#70004
Resolves rdar://119943672
Resolves rdar://119446012
ktoso added a commit to ktoso/swift that referenced this pull request Jan 10, 2024
We recently fixed a similar issue where the objects created from
decodeNextArgument in a distributed thunk were not properly destroyed.
The fix was in swiftlang#65952

In that fix, we missed handling of Indirect_In_Guaranteed which also
need to be destroyed, this patch corrects that omission.

Resolves swiftlang#70004
Resolves rdar://119943672
Resolves rdar://119446012
ktoso added a commit to ktoso/swift that referenced this pull request Jan 10, 2024
We recently fixed a similar issue where the objects created from
decodeNextArgument in a distributed thunk were not properly destroyed.
The fix was in swiftlang#65952

In that fix, we missed handling of Indirect_In_Guaranteed which also
need to be destroyed, this patch corrects that omission.

Resolves swiftlang#70004
Resolves rdar://119943672
Resolves rdar://119446012
ktoso added a commit that referenced this pull request Jan 11, 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.

Remote target (for distributed actor) arguments are not properly deinitialized
3 participants