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

Add truncated stack trace metadata to event tags #4742

Open
philprime opened this issue Jan 22, 2025 · 1 comment
Open

Add truncated stack trace metadata to event tags #4742

philprime opened this issue Jan 22, 2025 · 1 comment

Comments

@philprime
Copy link
Contributor

philprime commented Jan 22, 2025

Problem Statement

In the case of an infinite recursion, the stack trace exceeds the maximum number of frames we upload, and therefore gets truncated at the top, leaving only information where the process was killed and not where error originates from.

As recursions can happen inside OS frameworks, i.e. inside SwiftUI when a view uses itself in the body, the stack trace might not even contain any frames from the app, but only internal frames.

It might be possible to understand a recursion is happening by looking at the stack trace and seeing repeated frames, in other cases it might not be, therefore the crash itself is not helpful in solving the issue.

Example crash shown in Sentry product:

Image Image

Additional observation from a simple example:

recurse(i: 1)

func recurse(i: Int) {
  recurse(i: i + 1)
}

This only shows two frames in the full stack trace (maybe because they are both lines of in-app code). When looking at a stack trace happening in SwiftUICore, it shows a much larger stack trace (with no in-app stack available)

Solution Brainstorm

As the number of frames in the stack trace is limited on purpose, we can not include the full stack trace (could be many tens of thousands of repeating frames).

Instead we should add the following data points to the event payload:

  1. Is truncated? (Boolean)
  2. Number of frames in stack trace
  3. Recursion detected? (Boolean)

I believe 1 and 2 to be easy to implement, but 3 could be more complicated or simply too much work for the SDK and could instead be an addition for the backend.

Are you willing to submit a PR?

Yes! 🙌

@philprime
Copy link
Contributor Author

philprime commented Jan 29, 2025

There is an initiative to change the Data Modification Inventory going on, where we should have an official place to add this data.

@philprime philprime moved this from Needs Discussion to Blocked in Mobile & Cross Platform SDK Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Blocked
Development

No branches or pull requests

1 participant