sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

SwiftUI names are not demangled

Open sindresorhus opened this issue 1 year ago • 5 comments

Platform

macOS

Environment

Production

Installed

Swift Package Manager

Version

8.24.0

Did it work on previous versions?

No

Steps to Reproduce

Look at this report: https://sindresorhus.sentry.io/share/issue/0e4faa9089734b2bbe498a1e876fb30e/

In the stack trace:

7SwiftUI4ViewRzlAA15ModifiedContentVyxAA16OnSubmitModifierVGAaBHPxAaBHD1__AfA0cH0HPyHCHCTm 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA21_DefaultFocusModifierVGAaBHPxAaBHD1__AfA0cH0HPyHCHCTm

Expected Result

I expected them to be demangled.

Actual Result

They are not demangled.

Are you willing to submit a PR?

No

sindresorhus avatar Apr 27 '24 06:04 sindresorhus

Thanks for opening this. It might be related to https://github.com/getsentry/sentry-cocoa/issues/3081.

philipphofmann avatar Apr 29 '24 14:04 philipphofmann

I dug into this a little bit, and it turns out that when you use Verbose Function Names, both of these are prefixed with get_witness_table , which is being generated right here:

https://github.com/apple/swift/blob/3caef440583aa16ff0164395899b6e87e234f427/lib/IRGen/GenReflection.cpp#L519-L522

Swifts own demangler does not recognize that, as is it does not start with a proper swift mangling prefix. (Admittedly, our demangler is based on Swift 5.5.1 which is a bit out of date)

However, if I replace that with the proper prefix ($s), I get the following:

  • <A>concrete protocol conformance ModifiedContent<A, OnSubmitModifier>protocol conformance ref (type's module) Viewdependent root protocol conformance #0 AViewconcrete protocol conformance OnSubmitModifierprotocol conformance ref (type's module) ViewModifier
  • <A>concrete protocol conformance ModifiedContent<A, _DefaultFocusModifier>protocol conformance ref (type's module) Viewdependent root protocol conformance #0 AViewconcrete protocol conformance _DefaultFocusModifierprotocol conformance ref (type's module) ViewModifier

That is quite a mouthful, and TBH I have no idea what any of that means.

Long story short, the compiler has to output a proper swift symbol with the proper prefix for it to be demangled properly.

Swatinem avatar May 22 '24 14:05 Swatinem

But it might also be related to #3081 as @philipphofmann mentioned, as its quite possible that we just end up trying to demangle the name of some static data table because we lack access to proper debug symbols.

Swatinem avatar May 22 '24 14:05 Swatinem

If I got it right @Swatinem, except from doing https://github.com/getsentry/sentry-cocoa/issues/3081 there isn't much we can do right now, except to wait for Apple to provide proper dSYMs for SwiftUI?

philipphofmann avatar May 22 '24 14:05 philipphofmann

Indeed, we need to have a proper dSYM, otherwise its hard to move forward on any of this.

Swatinem avatar May 22 '24 14:05 Swatinem