Skip to content

Conversation

@jrose-apple
Copy link
Contributor

If we can't resolve a cross-reference unambiguously, we're supposed to produce an llvm::Error and let the calling code handle it. However, if we couldn't even resolve the type of the cross-reference, we would just crash. Follow the supported error path in that case too – in many cases the error can just propagate upwards to something that can handle it.

rdar://problem/34821187, plus an extra test case from rdar://problem/35157494. (The latter will be fixed better later, but meanwhile let's not regress on the crashing part.)

If we can't resolve a cross-reference unambiguously, we're supposed to
produce an llvm::Error and let the calling code handle it. However, if
we couldn't even resolve the /type/ of the cross-reference, we would
just crash. Follow the supported error path in that case too -- in
many cases the error can just propagate upwards to something that can
handle it.

rdar://problem/34821187, plus an extra test case from
rdar://problem/35157494. (The latter will be fixed better later, but
meanwhile let's not regress on the crashing part.)

Type filterTy = getType(TID);
if (!isType)
Type filterTy;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to avoid the copy and paste here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The top-level part and the non-top-level part are pretty different, but I can see if there's enough in common to factor it out more than it is. It's still going to be ugly because of the need for the early return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't think there's really a good way to avoid this. Only this section is copy/pasted, and because of the way llvm::Error works, you'd still end up with most of the duplication and a less clear building up of pathTrace. Maybe if we had a monadic try in C++.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

LGTM. I wonder how many more of these crashes are lurking.

@jrose-apple
Copy link
Contributor Author

Ideally we'd excise all uses of the old APIs, or at least outside of SIL deserialization, but I tried that the first time and it was way too big a change. I did do an audit when the "checked" variants first went in but clearly it wasn't perfect.

@jrose-apple jrose-apple merged commit a69656f into swiftlang:master Nov 15, 2017
@jrose-apple jrose-apple deleted the not-your-type branch November 15, 2017 17:32
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