Skip to content

ClosureLifetimeFixup: Handle undef partial_apply arguments gracefully #28805

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

Conversation

aschwaighofer
Copy link
Contributor

We have to handle undef partial_apply arguments to handle the following
source gracefully during the diagnosis pipeline.

class TestUndefined {
  private var stringList: [String]!

  func dontCrash(strings: [String]) {
    assert(stringList.allSatisfy({ $0 == stringList.first!}))
    let stringList = strings.filter({ $0 == "a" })
  }
}

rdar://57893008

We have to handle undef partial_apply arguments to handle the following
source gracefully during the diagnosis pipeline.

```
class TestUndefined {
  private var stringList: [String]!

  func dontCrash(strings: [String]) {
    assert(stringList.allSatisfy({ $0 == stringList.first!}))
    let stringList = strings.filter({ $0 == "a" })
  }
}
```

rdar://57893008
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

A question and a thought.

  1. Shouldn't a destroy_value on undef or a destroy_addr on undef just be a no-op? What was the specific crash?
  2. I imagine this is a greater problem in the optimizer. I bet you that if we had a pass that changed random values to be undef, we would catch a ton of bugs. Not saying you need to do that here though. For instance, what about mandatory inlining.

Beyond that in the local the code looks ok locally. Can I get my question above answered, then I LGTM?

@aschwaighofer
Copy link
Contributor Author

aschwaighofer commented Dec 16, 2019

We call insertDestroyOfCapturedArguments which calls releasePartialApplyCapturedArg which calls if (arg->getFunction()->hasOwnership()) to figure out whether it should call createDestroyValue.

arg->getFunction() is null.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7d09aee

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7d09aee

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM!

@aschwaighofer aschwaighofer merged commit 8b45b5a into swiftlang:master Dec 16, 2019
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