getsentry / sentry-cocoa

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

CreateStacktrace helper method #3907

Open philipphofmann opened 5 months ago

philipphofmann commented 5 months ago

Description

Write a helper method that creates a SentryStacktrace by passing in a list of raw stack memory addresses similar to what native offers with sentry_value_new_stacktrace, so that users can build their own events with their custom stacktraces. This can be reused for https://github.com/getsentry/sentry-cocoa/issues/741.

This came up here https://github.com/getsentry/sentry-cocoa/issues/741#issuecomment-2077339070:

Being able to attach a custom stack trace to events would be quite useful for some type of errors. In my project we're using Chromium's zombie detector to detect some security and stability issues. When a zombie access is detected we get a breadcrumb containing an array of stack address indicating where the dealloc happened. Being able to symbolize this stack trace and add it to the event would be incredibly useful as it'd give us crash reports that clearly indicate where an object has been dealloc'd and where it is being accessed.

We do something similar when creating converting the MetricKit payloads to SentryFrames in our SentryMetricKitIntegration:

https://github.com/getsentry/sentry-cocoa/blob/d6ff82cd1e1d0d263fb1a7358b09bd0a08df013e/Sources/Sentry/SentryMetricKitIntegration.m#L417-L435

We also need to ensure that the correct debug meta data is attached.

sebmarchand commented 4 months ago

Any rough ETA for this ? No pressure but I'm trying to decide whether or not I should implement a temporary solution for now, I'm blocked by this for some bug investigations. I could probably figure out how to do this based on the instructions provided above, just want to make sure that we're not both doing the same work in parallel! I'm just slightly concerned that I'm not familiar enough with the Sentry codebase to provide a "clean" implementation of this.

philipphofmann commented 4 months ago

I'm sorry we can't give you an ETA on this, as we don't see a high demand for this at the moment.

sebmarchand commented 4 months ago

No worries! In this case I'll implement a temporary solution myself, I'll share it here (or via a PR) if it's not too ugly 😅 .