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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation regression runtime The Swift Runtime swift 5.0

Comments

@swift-ci
Copy link
Collaborator

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

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

cc @eeckstein, @mikeash

@eeckstein
Copy link
Member

cc @rjmccall, @DougGregor

@rjmccall
Copy link
Member

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

@jckarter
Copy link
Member

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

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

@jckarter
Copy link
Member

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

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

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 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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation regression runtime The Swift Runtime swift 5.0
Projects
None yet
Development

No branches or pull requests

6 participants