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

Attachments only including a single line during hard crashes #4810

Closed
MattJustMatt opened this issue Feb 7, 2025 · 1 comment
Closed

Attachments only including a single line during hard crashes #4810

MattJustMatt opened this issue Feb 7, 2025 · 1 comment

Comments

@MattJustMatt
Copy link

Platform

iOS

Environment

Production

Installed

CocoaPods

Version

8.44

Xcode Version

16

Did it work on previous versions?

No response

Steps to Reproduce

    void Platform_Interop::sentry_init() {
        String platform = "apple";
        String realm = "client";
        String release = tprint("%-%@%", platform, realm, AO_COMMIT_HASH);
        NSString *ns_release = [NSString stringWithUTF8String:to_c_string(TEMP(), STACK_TRACE_NODE, release)];
        
        NSNumber *sampleRate = [NSNumber numberWithDouble:0.1];
        NSNumber *sampleRateError = [NSNumber numberWithDouble:1.0];
        
        [SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
            options.dsn = @"xxx";
            options.attachViewHierarchy = NO;
            options.enableMetricKit = NO;
            options.enableTimeToFullDisplayTracing = NO;
            options.swiftAsyncStacktraces = YES;
            options.sampleRate = sampleRateError;
            options.tracesSampleRate = sampleRate;
            options.releaseName = ns_release;
            options.enablePersistingTracesWhenCrashing = YES;
        }];

        String session_file_path = tprint("%/LOG-Client.txt", Platform_Interop::get_writable_directory(TEMP()));

        FILE *f = freopen((const char *)session_file_path.data, "r", stdout);
        if (f == NULL) {
            f = freopen((const char *)session_file_path.data, "w+b", stdout);
        }
        if (f != NULL) {
            fclose(f);
        }

        NSString *ns_session_file_path = [NSString stringWithUTF8String:to_c_string(TEMP(), STACK_TRACE_NODE, session_file_path)];
        SentryAttachment *fileAttachment = [[SentryAttachment alloc] initWithPath: ns_session_file_path];
        [SentrySDK configureScope:^(SentryScope *_Nonnull scope) {
            [scope addAttachment:fileAttachment];
        }];
    }

Exceptions captured normally with capture_event include the full session log, but if the application exits with a sigsegv or otherwise, the log only contains a single line.

We tried moving the init prior to clearing the session log on start in case hard crashes were being sent on next startup but this didn't appear to work either.

Example event: https://all-out-fb.sentry.io/issues/6274834837/events/oldest/attachments/?project=4505228624396288&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=oldest-event&statsPeriod=10m&stream_index=0

Expected Result

Full session log attachment same as when calling capture event normally

Actual Result

Single line log

Are you willing to submit a PR?

No response

@philipphofmann
Copy link
Member

We don't support attachments for crashes yet; see https://docs.sentry.io/platforms/apple/guides/ios/enriching-events/attachments/#uploading-attachments.

You will be able to do this by adding attachments in beforeSend (#1460), which would also work for crashes and we haven't tackled yet. I can't give you an ETA for this feature.

You can consider adding your info to breadcrumbs, which work for crashes. I'm closing this as duplicate of #1460.

@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants