getsentry / sentry-cocoa

The official Sentry SDK for iOS, tvOS, macOS, watchOS.
https://sentry.io/for/cocoa/
MIT License
797 stars 315 forks source link

SwiftUI names are not demangled #3914

Open sindresorhus opened 4 months ago

sindresorhus commented 4 months ago

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

philipphofmann commented 4 months ago

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

Swatinem commented 3 months ago

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:

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 commented 3 months ago

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.

philipphofmann commented 3 months ago

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?

Swatinem commented 3 months ago

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