Skip to content

Native backend uses physical attachment filename for hard crashes, instead of the name passed to USentryLibrary::CreateSentryAttachmentWithData() #1933

Closed

Description

@2957175722

Description

On Windows, the native backend can use the wrong attachment filename after a hard crash.

The application adds a file attachment and then sets a custom filename:

sentry_attachment_t *attachment =
    sentry_attach_file("C:\\temp\\archive-2026-07-31.zst");
sentry_attachment_set_filename(attachment, "game.log.zst");

A normal event shows game.log.zst, as expected. A hard-crash event shows archive-2026-07-31.zst, which is the basename of the physical path.

UE ensure events do not have this problem. They use the normal event path and read the current in-memory attachment. Only hard-crash events use the stale attachment manifest.

The cause is the order of these operations:

  1. sentry_attach_file(path) adds the attachment to the global scope.
  2. SENTRY_WITH_SCOPE_MUT immediately flushes the scope (sentry_core.c:2040-2068, sentry_scope.h:162-164, and sentry_scope.c:179-186).
  3. The native backend writes __sentry-attachments before the custom filename is set (sentry_backend_native.c:729-780, especially lines 757-760).
  4. sentry_attachment_set_filename changes the in-memory attachment, but it does not flush the scope (sentry_attachment.c:63-80).
  5. A normal event reads the current in-memory attachment and uses the custom filename (sentry_attachment.c:163-169 and sentry_envelope.c:722-751).
  6. The crash daemon reads the earlier attachment manifest and uses the physical basename (sentry_crash_daemon.c:3614-3658).

A later scope change can rewrite the manifest and hide the problem. Therefore, the result can depend on timing.

The Sentry UE wrapper calls these APIs in this order in GenericPlatformSentrySubsystem.cpp:411-419. The Windows implementation has the same order in MicrosoftSentrySubsystem.cpp:77-84. Project code only supplies the physical path and custom filename. The affected processing after that point is Sentry code.

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: All platforms where we use the Sentry native backend
  • Compiler: MSVC 14.38.33130
  • sentry-native version: 0.16.0
  • Sentry UE5 plugin version: 1.18.0

Steps To Reproduce

  1. Initialize sentry-native with SENTRY_BACKEND=native.
  2. Create C:\temp\archive-2026-07-31.zst.
  3. Add the attachment and set a different filename:
sentry_attachment_t *attachment =
    sentry_attach_file("C:\\temp\\archive-2026-07-31.zst");
sentry_attachment_set_filename(attachment, "game.log.zst");
  1. Capture a normal event. Confirm that its attachment filename is game.log.zst.
  2. Repeat the setup.
  3. Do not make another scope change after sentry_attachment_set_filename.
  4. Cause a hard crash.
  5. Inspect the attachment filename in the hard-crash event. It is archive-2026-07-31.zst instead of game.log.zst.

Log output

No relevant error is written to the log.

Expected: Ensure events, other normal events, and hard-crash events use game.log.zst.

Actual: Ensure events and other normal events use game.log.zst. Hard-crash events use archive-2026-07-31.zst.

Activity

  1. added
    Bug
    Native
    on Jul 31, 2026
  2. linear-code commented on Jul 31, 2026

    @linear-code
  3. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 31, 2026
  4. added
    Attachments
    on Jul 31, 2026
  5. 2957175722 commented on Jul 31, 2026

    @2957175722
    Author

    Update: it also looks like the mime type isn't being picked up as well - not 100% sure if its client side issue but I assume that it's just not being updated.

    For example, I'm setting the mimetype to application/zstd, and for ensures the preview option is greyed out in the web-app, but for crashes the preview option is available.

    Ensure:
    Image

    Crash:
    Image

  6. JoshuaMoelans commented on Jul 31, 2026

    @JoshuaMoelans
    Member

    Hi, thanks for reporting! This seems like a bug indeed, we're taking a look (at both the filename flushing & preview being missing for the same file depending on it being in the Ensure/Crash event)

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 31, 2026
  8. 2957175722 commented on Jul 31, 2026

    @2957175722
    Author

    @JoshuaMoelans

    Thanks for checking this out.

    Just want to make sure we are aligned here - the expected behaviour for an attachment with a mime type of "application/zstd" is that is will NOT be previewable in the web-app - but currently it is previewable in crashes, presumably because of the issue I reported.

  9. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 31, 2026
  10. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 31, 2026
  11. JoshuaMoelans commented on Jul 31, 2026

    @JoshuaMoelans
    Member

    @kjp-einosuke just to confirm, are you also setting the mimetype with sentry_attachment_set_content_type the same way you're setting the filename? (because then it's basically the same client-side issue of not flushing these attachment updates to the scope)

  12. 2957175722 commented on Jul 31, 2026

    @2957175722
    Author

    @JoshuaMoelans

    I'm not directly calling the Sentry API; I'm using the Unreal Engine plugin, and calling USentryLibrary::CreateSentryAttachmentWithPath() to create attachments.

    That internall calls a function that returns a ISentryAttachment, which is just a container by the looks of it - I assume that the mimetype is picked up from there, and applied later on in the crash handling process.

  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 31, 2026
  14. added a commit that references this issue on Jul 31, 2026
    575513d
  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AttachmentsBugNative

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions