Skip to content

MemAccessUtils: change the interface of getProjectionPath to Optional value #18926

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 23, 2018

Conversation

shajrawi
Copy link

Sometions we don't have a projection path for each ref_elem_addr - fixes a compiler crash in Deferred in the Source Compatibility Suite

When checking if two storage locations are distinct from one another, play it safe in such a case.

radar rdar://problem/43403553

… value

Sometions we don't have a projection path for each ref_elem_addr - fixes a compiler crash in Deferred in the Source Compatibility Suite

When checking if two storage locations are distinct from one another, play it safe in such a case.
@shajrawi
Copy link
Author

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit 809764f into swiftlang:master Aug 23, 2018
@atrick
Copy link
Contributor

atrick commented Aug 23, 2018

How could we not be able to create the ProjectionPath? I'm concerned about the correctness of that case.

Please add a SIL test for that corner case.

@shajrawi
Copy link
Author

@atrick I just went with a debugger on the compatibility projects, this is why we don't have a projection path:

  // Do not inspect the body of types with unreferenced types such as bitfields
  // and unions. This is currently only associated with structs.
  if (Start->getType().aggregateHasUnreferenceableStorage() ||
      End->getType().aggregateHasUnreferenceableStorage())

Which means:

  /// Does this struct contain unreferenceable storage, such as C fields that
  /// cannot be represented in Swift?
  bool hasUnreferenceableStorage() const {

As to why this is happening in the case that crashes, I looked at the source code:
we have a Swift class with a C struct as one of its fields, we are doing a begin_access on the C struct.

@atrick
Copy link
Contributor

atrick commented Aug 24, 2018

Good. So we have a SIL unit test now, which we need for any bizarre corner case like this.

This check End->getType().aggregateHasUnreferenceableStorage() definitely doesn't apply to our problem. I have no idea who added it or why, but they should have added a unit test if they didn't want us to come along and remove it.

@atrick
Copy link
Contributor

atrick commented Aug 24, 2018

  if (Start->getType().aggregateHasUnreferenceableStorage() ||
      End->getType().aggregateHasUnreferenceableStorage())

Incidentally, this also looks like a horrible bug to me. If this is something that needs to be checked before constructing a Projection, then it needs to be checked in the Projection constructor so it covers all elements along the projection path except the End, which is the only value we don't need a Projection into.

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