Skip to content

IRGen: Always call metadata accessor for resilient types even when resilience bypass is enabled [4.2] #17736

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

Conversation

slavapestov
Copy link
Contributor

  • Description: The previous fix for rdar://problem/40034143 was incomplete, because I got the reduced test case working but the original test case was still broken. The problem is when you have a module dependency graph like A --> B --> C and A is built with -enable-resilience-bypass (ie, the LLDB REPL), B uses a type from C, and C is built with resilience enabled, then sometimes A would directly access type metadata for types defined in B, instead of going through metadata accessors. This was because to A, everything has a known size, so it thinks the metadata does not require runtime initialization; however when B was built, the size of types in C was not known, so B's types do require runtime initialization.

  • Risk: Low, the fix only changes behavior when generating code for the LLDB REPL.

  • Scope of the issue: Impacts CreateML and possibly other frameworks that use Foundation value types, which are resilient.

  • Origination: New in 4.2 when we enabled resilience for stdlib and overlays.

  • Bug: rdar://40034143 (re-opened)

  • Reviewed by: @rjmccall

…silience bypass is enabled

Otherwise, we might directly use uninitialized metadata, because we think
the type has a fixed size, even if it was defined in a different module
built with resilience.

Fixes <rdar://problem/40034143>, for real this time.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@rjmccall This is another hackaround for LLDB's lack of resiience support. PTAL?

@slavapestov slavapestov changed the title IRGen: Always call metadata accessor for resilient types even when resilience bypass is enabled IRGen: Always call metadata accessor for resilient types even when resilience bypass is enabled [4.2] Jul 4, 2018
// However, when -enable-resilience-bypass is on, we might be using a value
// type from another module built with resilience enabled. In that case, the
// type looks like it has fixed size to us, since we're bypassing resilience,
// but the metadata still requires runtime initialization, so its incorrect
Copy link
Contributor

Choose a reason for hiding this comment

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

"it's"

@rjmccall
Copy link
Contributor

rjmccall commented Jul 5, 2018

I don't really understand the resilience-bypass logic very well, but this looks fine inasmuch as it's something we ought to be able to remove later.

@slavapestov slavapestov merged commit 58da061 into swiftlang:swift-4.2-branch Jul 5, 2018
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.

2 participants