Skip to content
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

[SR-10721] Runtime fails to demangle superclass when a type used to satisfy the superclass's generic bound is used in a superficial way #53118

Open
swift-ci opened this issue May 21, 2019 · 10 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented May 21, 2019

Previous ID SR-10721
Radar rdar://problem/51084888
Original Reporter benpious (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 10.2.1 (10E1001).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, IRGen, Runtime
Assignee None
Priority Medium

md5: e3a6d08500afe670dfaea4a0748d9a1d

relates to:

  • SR-10600 Runtime fails to demangle superclass when superclass's generic constraints are satisified in a conditional conformance

Issue Description:

We have a `class C<T, U, V> where U: Switch`. Another class `MyPlugin: C<Context, OneCaseEnum, PluginType>` inherits from `C`.

Running the attached sample code causes it to fail with

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented May 21, 2019

Comment by Ben Pious (JIRA)

GenericLayer.zip

Here's a less complex version of a similar issue. This case has the quirk that it seemingly only manifests when the base class inherits from `NSObject`.

@belkadan
Copy link
Contributor

@belkadan belkadan commented May 21, 2019

@eeckstein
Copy link
Member

@eeckstein eeckstein commented May 21, 2019

@rjmccall
Copy link
Member

@rjmccall rjmccall commented May 21, 2019

Sounds like we aren't emitting the type metadata for `OneCaseEnum`.

@jckarter
Copy link
Member

@jckarter jckarter commented May 24, 2019

Looks like some different issues going on here. In the first GenericLayer.zip attachment, the problem goes away if I move `Base`, `C,` Subclass2`, and `G` all together into one file; it repros when they are in separate files.

@jckarter
Copy link
Member

@jckarter jckarter commented May 24, 2019

It looks like the problem happens when `Base` and `Subclass2` are in different files.

@jckarter
Copy link
Member

@jckarter jckarter commented May 24, 2019

Ah, these look like they are all variants of rdar://problem/47598583 — the necessary type metadata is in a .o file in the static archive that is getting dropped because it's only referenced by mangled names. If `-all_load` doesn't work for some reason, maybe you could try `-force_load`-ing the specific static libraries.

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented May 29, 2019

Comment by Ben Pious (JIRA)

@jckarter thanks for investigating!

We're about to start investigating `-force_load`. Unfortunately we have over 350 static libraries, and this crash doesn't happen at startup. It also seems like unit tests aren't sufficient to guarantee that we've found all of them, as release builds can have totally different variants of these crashes, so doing it for specific libs may not be an option.

I assume that there's no reliable way to check the compiler's work, short of building with a toolchain that has the fix, and then diffing the nm output to see which symbols have changed.

@jckarter
Copy link
Member

@jckarter jckarter commented May 29, 2019

You should be safe if you force load any .a file that contains symbols matching the regex ^_?\$s.*Mn$ (that is, beginning with the prefix $s or _$s, and ending with the suffix Mn)

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Mar 6, 2020

Comment by Michael Eisel (JIRA)

In the Xcode 11 release notes, it states "Static libraries are now always force-loaded in their entirety during linking, fixing most “unable to demangle” runtime errors". Does that mean that it loads all object files of all static libraries? All of object files of all static libraries that have at least one Swift symbol? Or just all object files that have at least one Swift symbol?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants