Repository navigation
Description
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:
sentry_attach_file(path)adds the attachment to the global scope.SENTRY_WITH_SCOPE_MUTimmediately flushes the scope (sentry_core.c:2040-2068,sentry_scope.h:162-164, andsentry_scope.c:179-186).- The native backend writes
__sentry-attachmentsbefore the custom filename is set (sentry_backend_native.c:729-780, especially lines 757-760). sentry_attachment_set_filenamechanges the in-memory attachment, but it does not flush the scope (sentry_attachment.c:63-80).- A normal event reads the current in-memory attachment and uses the custom filename (
sentry_attachment.c:163-169andsentry_envelope.c:722-751). - 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
- Initialize sentry-native with
SENTRY_BACKEND=native. - Create
C:\temp\archive-2026-07-31.zst. - 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");- Capture a normal event. Confirm that its attachment filename is
game.log.zst. - Repeat the setup.
- Do not make another scope change after
sentry_attachment_set_filename. - Cause a hard crash.
- Inspect the attachment filename in the hard-crash event. It is
archive-2026-07-31.zstinstead ofgame.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.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Jul 31, 2026
NATIVE-209
2957175722 commentedon Jul 31, 2026
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:

Crash:

JoshuaMoelans commentedon Jul 31, 2026
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)
2957175722 commentedon Jul 31, 2026
@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.
JoshuaMoelans commentedon Jul 31, 2026
@kjp-einosuke just to confirm, are you also setting the mimetype with
sentry_attachment_set_content_typethe 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)2957175722 commentedon Jul 31, 2026
@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.fix(attachments): flush scope when attachment metadata changes