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_MUT immediately flushes the scope (sentry_core.c:2040-2068, sentry_scope.h:162-164, and sentry_scope.c:179-186).
- The native backend writes
__sentry-attachments before the custom filename is set (sentry_backend_native.c:729-780, especially lines 757-760).
sentry_attachment_set_filename changes 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-169 and sentry_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
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.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.
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:
A normal event shows
game.log.zst, as expected. A hard-crash event showsarchive-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).__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).sentry_attachment.c:163-169andsentry_envelope.c:722-751).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 inMicrosoftSentrySubsystem.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
Environment
Steps To Reproduce
SENTRY_BACKEND=native.C:\temp\archive-2026-07-31.zst.game.log.zst.sentry_attachment_set_filename.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 usearchive-2026-07-31.zst.