Skip to content

[AutoDiff] Fix PullbackCloner tangent value category mismatch crash #33512

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
Aug 18, 2020

Conversation

efremale
Copy link
Contributor

Fix semantic member getter pullback generation crash due to tangent value category mismatch.
Resolves SR-13411.

Fix semantic member getter pullback generation crash due to tangent value category mismatch.
Resolves SR-13411.
@efremale
Copy link
Contributor Author

cc @dan-zheng

@@ -2431,7 +2431,7 @@ bool PullbackCloner::Implementation::runForSemanticMemberGetter() {

// Switch based on the base tangent struct's value category.
// TODO(TF-1255): Simplify using unified adjoint value data structure.
switch (tangentVectorSILTy.getCategory()) {
switch (getTangentValueCategory(origSelf)) {
case SILValueCategory::Object: {
auto adjResult = getAdjointValue(origEntry, origResult);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: hypothetically, there may be a similar "tangent value category mismatch" hole on this line where getAdjointValue(origEntry, origResult) is called before checking that getTangentValueCategory(origResult) == SILValueCategory::Object.

I can't think of a trigger for this in practice (semantic member getter pullback generation for origSelf with object tangent value category but origResult with address tangent value category), so I think it's fine to skip it for now.

@@ -407,6 +407,7 @@ static CanSILFunctionType getAutoDiffDifferentialType(
// result's convention is indirect.
if (tl.isAddressOnly() && !isIndirectFormalResult(origResConv)) {
switch (origResConv) {
case ResultConvention::Unowned:
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: we could make this logic handle all ResultConvention cases.

But with this change, the three common ResultConvention cases are all handed (Unowned, Owned, Indirect). I haven't seen the other cases (UnownedInnerPointer, Autoreleased) appear in practice.

@dan-zheng dan-zheng requested review from marcrasi and rxwei August 17, 2020 21:56
@dan-zheng
Copy link
Contributor

@swift-ci Please smoke test

@dan-zheng dan-zheng merged commit a434ee8 into swiftlang:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants