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

CreateStacktrace helper method #3907

Open
philipphofmann opened this issue Apr 26, 2024 · 3 comments
Open

CreateStacktrace helper method #3907

philipphofmann opened this issue Apr 26, 2024 · 3 comments

Comments

@philipphofmann
Copy link
Member

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 #741.

This came up here #741 (comment):

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:

- (SentryStacktrace *)convertMXFramesToSentryStacktrace:(NSEnumerator<SentryMXFrame *> *)mxFrames
{
NSMutableArray<SentryFrame *> *frames = [NSMutableArray array];
for (SentryMXFrame *mxFrame in mxFrames) {
SentryFrame *frame = [[SentryFrame alloc] init];
frame.package = mxFrame.binaryName;
frame.inApp = @([self.inAppLogic isInApp:mxFrame.binaryName]);
frame.instructionAddress = sentry_formatHexAddressUInt64(mxFrame.address);
uint64_t imageAddress = mxFrame.address - mxFrame.offsetIntoBinaryTextSegment;
frame.imageAddress = sentry_formatHexAddressUInt64(imageAddress);
[frames addObject:frame];
}
SentryStacktrace *stacktrace = [[SentryStacktrace alloc] initWithFrames:frames registers:@{}];
return stacktrace;
}

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

@sebmarchand
Copy link

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
Copy link
Member Author

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
Copy link

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 😅 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Backlog
Development

No branches or pull requests

3 participants