You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Symbolication for AOT-compiled stack traces on iOS #2180
With SentryOptions.Debug = true, I now can see the problem:
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Info: Capturing event.
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Debug: Running processor on exception: This exception was thrown and captured manually, without crashing the app.
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Info: Skipping DebugImage for module 'Sentry.Samples.Maui.dll' because DebugId couldn't be determined
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Debug: Created DebugStackTrace with 1 frames.
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Debug: Running main event processor on: Event 42dbc64b0868418cad97794f1f95c39d
Feb 14 14:05:33 mattjs-iPhone Sentry.Samples.Maui[809] <Notice>: Debug: Merging 0 debug images from stacktrace.
And in the case of the released iOS app, MinorVersion is 0. I can get some parts of it working if I test with entry.Type == DebugDirectoryEntryType.CodeView instead. But the debug id doesn't fully match the PDB.
The problem appears to be caused by dotnet assembly trimming, which is not something that can be disabled for iOS apps. (I've tried various options with no success as of yet.)
Building in release mode will create a regular dll and pdb where you'd expect them. For example:
The PDB was uploaded with DebugID: c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-d0a102d4
The non-trimmed version will match: c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-d0a102d4
The trimmed version has a different one: c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-63ec4f2f
(Note the output of sentry-cli is showing -1 but the first 8 digits of the Code ID are what will actually be used there.)
I can see the same detail in Rider's "Assembly Explorer":
The non-trimmed DLL's debug headers:
The trimmed DLL's debug headers:
Notice that the non-trimmed version has valid values for MajorVersion and MinorVersion, the TimeDateStamp is a pseudo-timestamp (due to deterministic builds), and the Deterministic entry indicator is present.
In the non- trimmed headers, MajorVersion and MinorVersion are zero, and the TimeDateStamp field is a real value (the UTC time the linker ran), and the Deterministic entry is absent.
Not sure what to do about this. At runtime, we need the debug_meta information to contain the full original Debug ID to match with the one in the PDB sent to Sentry. There is no corresponding PDB to upload that will match the trimmed version.
One thought I had was that it might be possible to use an MSBuild tasks with ILLink custom steps to read the full debug ID from the un-trimmed assembly and write it to another location (such as an AssemblyMetadata attribute) in the trimmed assembly. We could read it from there at runtime.
Notice that the non-trimmed version has valid values for MajorVersion and MinorVersion, the TimeDateStamp is a pseudo-timestamp (due to deterministic builds), and the Deterministic entry indicator is present.
In the non- trimmed headers, MajorVersion and MinorVersion are zero, and the TimeDateStamp field is a real value (the UTC time the linker ran), and the Deterministic entry is absent.
Not sure what to do about this. At runtime, we need the debug_meta information to contain the full original Debug ID to match with the one in the PDB sent to Sentry. There is no corresponding PDB to upload that will match the trimmed version.
We may need to change the lookup logic to support this properly @Swatinem ?
@vaind - I think you're saying that I'm seeing the first part of the spec there (Version Major=0, Minor=0...), and we've designed only for the second part (Version Major=any, Minor=0x504d...)? In that case should we be sending the Age instead of the TimeDateStamp? Even then, I'm not sure how it would match up on the server side, as the pdb would still have the TimeDateStamp in its debug_id.
For completeness, it doesn't look like we can add support for this to MonoAOT because of the missing information. This is all the info we have available at runtime:
varrealFrame=stackFrame.FrameasStackFrame;_options.LogDebug("Capturing frame {0}",frame.ToUtf8Json());_options.LogDebug("### ToString = {0}",realFrame!.ToString());_options.LogDebug("### Has Native Image = {0}",realFrame.HasNativeImage());_options.LogDebug("### Native Image Base = 0x{0:x}",realFrame.GetNativeImageBase());_options.LogDebug("### Native Interface pointer = 0x{0:x}",realFrame.GetNativeIP());_options.LogDebug("### Offset = {0}",realFrame.GetNativeOffset());_options.LogDebug("### FileName = {0}",realFrame.GetFileName());_options.LogDebug("### Line no = {0}",realFrame.GetFileLineNumber());_options.LogDebug("### HasMethod = {0}",realFrame.HasMethod());_options.LogDebug("### Method = {0}",realFrame.GetMethod());_options.LogDebug("### ILOffset = {0}",realFrame.GetILOffset());_options.LogDebug("====================");
Has the following output (the first line is from another log line above in the normal code):
@vaind Just to clarify - so if we are using MonoAOT, we can expect that AOT compiled stack traces are not symbolicated? And working on switching to NativeAOT could help alleviate that?
Activity
mattjohnsonpint commentedon Feb 14, 2023
Note - works in debug mode. Also works in debug or release mode on the simulator - just not on a real device.
mattjohnsonpint commentedon Feb 14, 2023
Just a note, Android does not have this issue. It symbolicates fine:
https://sentry-sdks.sentry.io/issues/3929952795/events/395517c261754371a951f61970be83f0/?project=5428537
mattjohnsonpint commentedon Feb 14, 2023
Found I can get at at the logs in release mode by connecting the iOS device via USB and running:
With
SentryOptions.Debug = true, I now can see the problem:mattjohnsonpint commentedon Feb 15, 2023
Well, I found the problem.
sentry-dotnet/src/Sentry/Internal/DebugStackTrace.cs
Line 421 in 80ce485
This is returning false. It's defined as:
And in the case of the released iOS app,
MinorVersionis0. I can get some parts of it working if I test withentry.Type == DebugDirectoryEntryType.CodeViewinstead. But the debug id doesn't fully match the PDB.The problem appears to be caused by dotnet assembly trimming, which is not something that can be disabled for iOS apps. (I've tried various options with no success as of yet.)
Building in release mode will create a regular dll and pdb where you'd expect them. For example:
bin/Release/net6.0-ios/ios-arm64/Sentry.Samples.Maui.dllbin/Release/net6.0-ios/ios-arm64/Sentry.Samples.Maui.pdbBut then it will write a trimmed dll to the app bundle at:
bin/Release/net6.0-ios/ios-arm64/Sentry.Samples.Maui.app/Sentry.Samples.Maui.dllBoth dll's will have the same guid part of the debug id, but the last component (the timestamp) will vary.
Check with
sentry-cli:c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-d0a102d4c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-d0a102d4c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-63ec4f2f(Note the output of
sentry-cliis showing-1but the first 8 digits of the Code ID are what will actually be used there.)I can see the same detail in Rider's "Assembly Explorer":
The non-trimmed DLL's debug headers:
The trimmed DLL's debug headers:
Notice that the non-trimmed version has valid values for
MajorVersionandMinorVersion, theTimeDateStampis a pseudo-timestamp (due to deterministic builds), and theDeterministicentry indicator is present.In the non- trimmed headers,
MajorVersionandMinorVersionare zero, and theTimeDateStampfield is a real value (the UTC time the linker ran), and theDeterministicentry is absent.mattjohnsonpint commentedon Feb 15, 2023
Not sure what to do about this. At runtime, we need the
debug_metainformation to contain the full original Debug ID to match with the one in the PDB sent to Sentry. There is no corresponding PDB to upload that will match the trimmed version.One thought I had was that it might be possible to use an MSBuild tasks with ILLink custom steps to read the full debug ID from the un-trimmed assembly and write it to another location (such as an
AssemblyMetadataattribute) in the trimmed assembly. We could read it from there at runtime.@bruno-garcia @vaind - thoughts?
mattjohnsonpint commentedon Feb 15, 2023
Oh, and note that both parts of the Code ID differ as well.
Debug ID:
c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-d0a102d4Code ID:
d0a102d41c000Signature:
c66dceee-2c72-4bf6-9a15-6e2aad6ab8fbTimeDateStamp:
d0a102d4SizeOfData:
1c000vs.
Debug ID:
c66dceee-2c72-4bf6-9a15-6e2aad6ab8fb-63ec4f2fCode ID:
63ec4f2fc000Signature:
c66dceee-2c72-4bf6-9a15-6e2aad6ab8fbTimeDateStamp:
63ec4f2fSizeOfData:
c000... which makes sense because the trimmed version is smaller, and the timestamp of the non-trimmed version is deterministic
vaind commentedon Feb 15, 2023
Seems to match the specification
We may need to change the lookup logic to support this properly @Swatinem ?
mattjohnsonpint commentedon Feb 15, 2023
@vaind - I think you're saying that I'm seeing the first part of the spec there (
Version Major=0, Minor=0...), and we've designed only for the second part (Version Major=any, Minor=0x504d...)? In that case should we be sending theAgeinstead of theTimeDateStamp? Even then, I'm not sure how it would match up on the server side, as the pdb would still have theTimeDateStampin itsdebug_id.vaind commentedon Feb 15, 2023
I'm not very familiar with the symbolication part of this, that's why I've tried pinging @Swatinem, I think he have originally programmed that.
vaind commentedon Feb 15, 2023
But yes, my suspicion is we're not handling both scenarios.
13 remaining items
mattjohnsonpint commentedon Apr 17, 2023
Blocked on https://github.com/getsentry/team-stacktrace/issues/43. Will resume later.
bruno-garcia commentedon Jul 24, 2023
We possibly can support iOS through Native AOT for apps targeting .NET 8 and later. Assuming this lands:
If so, this ticket, given its complexity, becomes lower priority. That is, if Mono AOT can be replaced with Native AOT.
And what we could focus on is:
SamMonoRT commentedon Aug 11, 2023
We'll encourage you to try steps for NativeAOT targetting iOS as mentioned in this blog post on any .NET8 Preview 6 or 7 builds and give us feedback - https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-6/#support-for-targeting-ios-platforms-with-nativeaot
vaind commentedon Nov 11, 2023
@bruno-garcia @SamMonoRT support for NativeAOT on .net8-ios works fine with Sentry, I'm preparing a PR #2820
vaind commentedon Dec 5, 2023
For completeness, it doesn't look like we can add support for this to MonoAOT because of the missing information. This is all the info we have available at runtime:
Has the following output (the first line is from another log line above in the normal code):
jurganson commentedon Mar 10, 2025
@vaind Just to clarify - so if we are using MonoAOT, we can expect that AOT compiled stack traces are not symbolicated? And working on switching to NativeAOT could help alleviate that?