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

Stack trace from errors in Windows does not link to the source code

Open homuler opened this issue 1 year ago • 2 comments

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which version of the SDK? 2.1.0

How did you install the package? (Git-URL, Assetstore) Git-URL

Which version of Unity? 2021.3.2f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows? This is occurring on the player, but it's an issue related to how the errors sent to Sentry are displayed (in the Web UI).

Steps to Reproduce

  1. Install and Configure the Sentry SDK

    • Here is the Debug Symbols settings Image
  2. Build the app (Windows Standalone, IL2CPP)

    • We're using a script that calls BuildPipeline.BuildPlayer
  3. Distribute the app to the users.

  4. Some kind of error occurs while the user is using the app.

Expected Result

I expect each line of the stack trace to be linked to the source code. In fact, we are also building the app for macOS, and when an error occurs there, we can view the source code.

To avoid exposing our app's code, I will attach a screenshot of an error occurring purely in Unity's code. As shown below, the source code is available.

Image

Actual Result

Unlike when built for macOS, we cannot view the source code in the Stack Trace for errors that occur in the Windows app. The following screenshot shows the Stack Trace of the same error that occurred on macOS, but this time on Windows.

Image

Any logs or screenshots

It appears that the following command was executed when uploading debug files.

"sentry-cli-Windows-x86_64.exe" "debug-files" "upload" "--il2cpp-mapping" "--include-sources" "ourapp.exe" "UnityPlayer.dll" "ourapp_Data/Plugins/x86_64/sentry.dll" "C:\Path\To\Library\PackageCache\io.sentry.unity@912a177efe\Plugins\Windows\Sentry\sentry.pdb" "ourapp_BackUpThisFolder_ButDontShipItWithYourGame" "GameAssembly.dll"

Additionally, based on the 'Images Loaded' section, it seems at first glance that the corresponding source code was successfully uploaded. Image

homuler avatar Sep 12 '24 09:09 homuler

Hey @homuler, sorry to see you run into issues. Can you share the link to a windows issue with me at [email protected]?

bitsandfoxes avatar Sep 12 '24 10:09 bitsandfoxes

@bitsandfoxes Thank you for your prompt reply. I have just sent the link via email.

homuler avatar Sep 12 '24 10:09 homuler

We're also encountering this issue (pdb files are being uploaded, but stack trace does not have source code). Let me know if there is anything we can do to help.

EDIT:

I tried downloading the .pdb file, and inspecting it with https://github.com/getsentry/pdb :

cargo run --example pdb_lines C:\Users\user\Downloads\ca0b525b-25f6-443c-b42d-82ddd5eae12d-f903c118.pdb
error dumping PDB: UnrecognizedFileFormat

I tried inspecting it with the linux file command, and that reports:

~/D…/file_5.44-build104-vs2015-x64 .\file.exe C:\Users\johhel\Downloads\ca0b525b-25f6-443c-b42d-82ddd5eae12d-f903c118.pdb
C:\Users\user\Downloads\ca0b525b-25f6-443c-b42d-82ddd5eae12d-f903c118.pdb: Microsoft Roslyn C# debugging symbols version 1.0

So perhaps something is wrong with Sentry's pdb parsing that it doesn't support newer formats.

EDIT2: We're runing Sentry 25.3.0, and "io.sentry.unity": "https://github.com/getsentry/unity.git#3.2.0",

Image

johanhelsing-attensi avatar Aug 11 '25 14:08 johanhelsing-attensi

Hey @johanhelsing-attensi, thanks for the sleuthing! Could you share the event with us?

bitsandfoxes avatar Aug 12 '25 11:08 bitsandfoxes

@bitsandfoxes certainly, but how do I do it? It's on a self-hosted sentry instance. Any way to export an event?

johanhelsing-attensi avatar Aug 12 '25 13:08 johanhelsing-attensi

You can try running debuginfo_debug instead of the pdb crate, which does not support portable pdbs, which this very likely is.

Ideally you reproduce the entire issue on the SaaS version, this is by far the easiest for us. Otherwise we'd at least need all the relevant files you uploaded to Sentry and the entire JSON of the event.

@bitsandfoxes might have an example or docs how to set this up and maybe you can tackle it from this side, start with a minimal example and look for differences from that setup to your real setup.

Dav1dde avatar Aug 12 '25 14:08 Dav1dde

@johanhelsing-attensi, @homuler, any chance that you've been building with Mono as scripting backend?

bitsandfoxes avatar Aug 27 '25 11:08 bitsandfoxes

We used to build our app with Mono as the scripting backend, but by the time I reported this issue, we had already switched to IL2CPP.

homuler avatar Aug 27 '25 11:08 homuler

we had already switched to IL2CPP.

Are you still running into issues? I just closed https://github.com/getsentry/sentry-unity/issues/1763#issuecomment-3227674864 related to missing line numbers and source code on Mono. TLDR; ManagedCodeStripping needs to be disabled, Unity completely strips the debug information out of the assembly otherwise.

bitsandfoxes avatar Aug 27 '25 14:08 bitsandfoxes

Since there might be some misunderstanding, let me clarify:

  1. This issue occurs in IL2CPP builds and has nothing to do with Mono.
    • I only mentioned having used Mono before because I was asked, but that was before this issue ever happened.
  2. This issue occurs only on Windows and not on macOS, Android, or iOS.

If it has already been addressed in the latest version, feel free to close this issue, but the fix you mentioned doesn’t seem to be related.

homuler avatar Aug 27 '25 15:08 homuler

My bad, I mixed up what this issue was about. Apologies, it's been taking so long to get back to this. You don't happen to have a link to one of those events around? Or some build logs?

bitsandfoxes avatar Aug 28 '25 20:08 bitsandfoxes

I sent the link at that time. However, since I left the company I was working for back then, I can’t send the link again, sorry.

homuler avatar Sep 01 '25 05:09 homuler

Sorry for the delay and not having looked at this back then when there was an example event. without a repro now it's challenging and since this was reported a while ago and we haven't seen it since then, it's possible this was already fixed.

I'll close this for now but we'll reopen if it comes up again

bruno-garcia avatar Sep 03 '25 12:09 bruno-garcia