Skip to content

feat!: 1.0 - #2196

Open
jpnurmi wants to merge 148 commits into
masterfrom
v1
Open

jpnurmi wants to merge 148 commits into
masterfrom
v1

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Warning

WIP    🚧🔨⏳⛔

Close: #2044

#skip-changelog (WIP)

Run CI on `v1` like on `master`, and dispatch console compatibility
checks to the same-named console branch for commits cut from `v1`.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread .github/workflows/console-check.yml Resolved
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.84988% with 1089 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.86%. Comparing base (312ed43) to head (8e1af43).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2196      +/-   ##
==========================================
+ Coverage   75.71%   75.86%   +0.14%     
==========================================
  Files         104      105       +1     
  Lines       28706    31331    +2625     
  Branches     5265     5844     +579     
==========================================
+ Hits        21736    23769    +2033     
- Misses       5609     6121     +512     
- Partials     1361     1441      +80     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The collective PR runs CI on every push to v1 already.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread .github/workflows/codeql.yml Resolved
Pull request analyses are stored against the merge ref, so PRs into v1
had no baseline and compared against master.
* ci: include version in the release archive name

Fixes: #745

* ci: keep a stable archive name for latest downloads

Create a `sentry-native.zip` copy for the GCS `latest/` path so each
release replaces the same object. Keep versioned archive names for
GitHub and version-specific GCS paths.
BREAKING CHANGE: Linux, macOS, and Windows builds now default to the
`native` backend instead of `crashpad`.
The custom capture hook required private SDK types, while screenshot
options were still experimental.

BREAKING CHANGE: Implement sentry_screenshot_capture(const char *,
uint32_t), returning 0 on success.
The factory used a private-style `sentry__`-prefixed name even though
custom transports must provide its implementation. Give it a public-style
name and document the contract for custom implementations.

BREAKING CHANGE: Custom transport implementations must define:
```
sentry_transport_t *sentry_transport_new_default(void)
```

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/sentry_options.c Resolved
Keep the scope write lock across a batch while allowing the owning thread
to use existing scope accessors without relocking. Defer backend scope
flushes until the outermost batch completes.
Split the existing global scope into an internal, read-only global
scope for SDK/OS metadata and configured defaults, and a mutable
isolation scope used by top-level APIs. Move user data, observers, and
backend flushing to the isolation scope.

Add `sentry_scope_acquire()` and `sentry_scope_release()` for direct
isolation scope access.

Implement Sentry's three-scope model with global -> isolation -> local
scope layering. Retain parent references and merge layers when preparing
events, telemetry, and attachments. Local values take precedence over
isolation and global defaults.

The SDK follows the global mode used by other Sentry SDKs for client
applications: all threads share the same process-wide isolation scope.
Changes made through top-level APIs or an acquired reference are shared
across all threads.

See:
- https://develop.sentry.dev/sdk/foundations/state-management/scopes/#isolation-scope

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/sentry_scope.c Resolved
Provide exception metadata, registers, and a basic crashing-thread stack
for crash identification in native `on_crash`, matching `inproc`.
Use the same payload for `before_send` when `on_crash` is unset.

- Capture up to 128 fault-context IPs and unwind source in shared memory.
  Retain the faulting IP when available.
- Linux: SDK `libunwind` with signal-safe logging.
- macOS: SDK frame-pointer walker, guarded Mach reads, PAC stripping,
  `__DARWIN_OPAQUE_ARM_THREAD_STATE64` accessors, and
  `instruction_addr_adjustment=none`.
- Android/Linux without `libunwind`: bounded frame-pointer capture via
  `process_vm_readv`; avoids `libunwindstack`'s C++ allocation.
- Windows: MSVC x64 `RtlLookupFunctionEntry`/`RtlVirtualUnwind` walking
  without DbgHelp; SP progress permits recursive frames.
  Frame-pointer capture on x86/ARM64 and other x64 builds.
- ARM32 frame-pointer fallbacks retain only the faulting IP.

The daemon reuses partial captures and enriches existing frames.
Preserve exception/register/frame edits and removals, and honor callback
rejection.
Promote the 5-6 years old module API, also used by downstream SDKs,
now that it's usable for direct Native SDK users for comparing frame
addresses with module ranges.

Ref: #2102
Ref: #2116

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Skip Windows frame symbol lookup when symbolize_stacktraces is
disabled, including crash frames captured before daemon processing.
Add length-prefixed frames and app-to-daemon IPC based on Unix domain
stream socket pairs and an anonymous pipe on Windows.

Ref: #1834
* perf(native): Sync scope over IPC

Instead of flushing the whole scope/event on disk on every scope
change, send an initial scope snapshot and then minimal incremental
updates to the crash daemon over IPC.

Keep the latest complete state in daemon memory for crash reports.
Discard interrupted messages and preserve crash callback changes through
a final event and attachment snapshot.

Close: #1834

* handle SENTRY_CRASH_STATE_CRASHING

* signal.h

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@jpnurmi jpnurmi added the v1 Targets 1.0 (v1 branch) label Oct 16, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

The inproc-based Android NDK uses `SENTRY_TRANSPORT=none` and installs
a JNI function transport that writes to `outbox/`, leaving HTTP delivery
to Java. Tests substitute it with an stdout callback to inspect envelopes
without Java or HTTP.

However, the Native daemon in #1725 cannot use the function transport
from the separate daemon process. Provide (an internal) built-in stdout
transport (`SENTRY_TRANSPORT=stdout`) that both the SDK and daemon can
instantiate. This is mostly for out own integration testing purposes,
but it's also super handy for quick experiments:

```sh
$ make build SENTRY_BACKEND=inproc SENTRY_TRANSPORT=stdout
...
$ ./build/sentry_example_crash
...
[sentry] DEBUG sending envelope
{"event_id":"0e1d5355-5ba8-42cb-9e96-c6610d4ee9c1",...}
{"type":"event","length":2823}
{"event_id":"0e1d5355-5ba8-42cb-9e96-c6610d4ee9c1","timestamp":"2026-10-16T16:19:26.968633Z","platform":"native","level":"fatal","exception":...}
[sentry] INFO entering signal handler
...
```
Comment thread src/backends/native/sentry_crash_ipc.c Resolved
Comment thread tests/unit/test_native_backend.c Resolved
The last nonblocking flush in `crash_ipc_awaiting_ready` can leave part
of the release frame unread. The snapshot that follows is a blocking
send, so with too little buffer space left, it can time out and fail
the test. Receive once after the flush loop, as
`crash_ipc_stalled_stream` does.

Ref: #2196 (comment)
sentry-dotnet preloads the crash handler so that it is installed before
the .NET runtime's `SIGSEGV` handler, which turns null dereferences in
Native AOT-compiled managed code into `NullReferenceException`.

With the handler already installed (#2268), `sentry__crash_handler_init()`
ignored its callback (#2220), so sentry-crash never called `dump_crash_queue()`.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

# Conflicts:
#	include/sentry.h
#	ndk/gradle.properties
#	src/sentry_thread_stackwalk_posix.c
#	tests/__init__.py
* fix(native): Recover interrupted crash reports

If the crash daemon is killed abruptly, or has not attached yet, the
crash is lost: the next launch deletes its `__sentry-event` with the
old run folder. This is more likely on Android, where the daemon runs
in a service process that the system can kill independently of the
app, for example under memory pressure, and that may not have connected
yet when the app crashes. Recover the event instead. The daemon removes
the file once it has sent the crash or kept its own envelope.

* Update CHANGELOG.md

* fix(native): Recover the crash envelope of an interrupted daemon

A daemon killed after writing `__sentry-crash.envelope` but before
removing `__sentry-event` left both files, and the next launch invoked
`on_crashed_last_run` for each. Send the daemon's envelope instead and
remove the event.

* test(native): verify which crash the recovery sends

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a29bd9f. Configure here.

jpnurmi and others added 7 commits November 24, 2026 12:49
* fix(native): Recover interrupted crash reports

If the crash daemon is killed abruptly, or has not attached yet, the
crash is lost: the next launch deletes its `__sentry-event` with the
old run folder. This is more likely on Android, where the daemon runs
in a service process that the system can kill independently of the
app, for example under memory pressure, and that may not have connected
yet when the app crashes. Recover the event instead. The daemon removes
the file once it has sent the crash or kept its own envelope.

* Update CHANGELOG.md

* fix(native): Recover the crash envelope of an interrupted daemon

A daemon killed after writing `__sentry-crash.envelope` but before
removing `__sentry-event` left both files, and the next launch invoked
`on_crashed_last_run` for each. Send the daemon's envelope instead and
remove the event.

* fix(android): Fall back to a file for crash IPC without memfd

`memfd_create` needs Linux 3.17, so creating the crash service's
shared memory failed on older kernels, and the SDK disabled native
crash reporting.

When `memfd_create` fails, create an unlinked file in the database
directory instead. Preallocate it with `posix_fallocate()`, because a
sparse file raises `SIGBUS` on write when the disk is full. Java passes
the directory to the new `SentryNdk.createCrashShm(String)` overload,
and `createCrashShm()` keeps using memfd only.

* docs(android): Say that createCrashShm() needs memfd

The overload without a database directory has no file fallback, so it
needs a kernel with memfd rather than a specific API level.

* ci(android): Run the e2e tests on API 21, 26, 31 and 35

Match the Android API levels and NDK versions in `ci.yml`. The crash
IPC now works without memfd, so drop the fixture's API 30 `minSdk`
and the tests' API 30 skips.

* ci(android): Check out the sentry-java API 21 branch for e2e tests

The API 21 and 26 e2e jobs need the sentry-java side of running the
crash service below API 30.

* Update CHANGELOG.md

* test(android): Fix the e2e tests on API 31 and 36

API 31 tombstones leave dex frames unnamed, so the merged event has no
Java method names. Check them only on later API levels.

The fixture crashed 1 s after setting the scope, but sentry-java syncs
the scope to native on its single-threaded executor, behind the startup
work of the tombstone integration. Now that the crash service starts
without waiting, that work can still run when the crash fires, and the
event misses the `test.id` tag. Queue the crash on the executor, so
that it follows the scope sync.

Print logcat when an Android e2e test fails.

* test(android): Run the native backend tests on API 21

`has_native` was false below API 23, so the API 21 e2e job skipped
all Android tests and never exercised the file fallback for crash IPC.
API 21 is the minimum, so drop the Android clause.

* test(android): Replace undecodable bytes in the logcat dump

A non-UTF-8 byte in `adb logcat` output raised `UnicodeDecodeError`
in the fixture teardown and lost the logcat dump of a failed test.

* test(android): Run the native backend integration test on API 21

The API 23 skip blamed `process_vm_readv`, but below API 23
`sentry__process_vm_readv()` calls the raw syscall.

* ci(android): Use the default emulator image for e2e tests

The e2e tests do not use Google Play services. Use the smaller AOSP
images, like the regular Android CI jobs.

* fix(android): Don't wait for the crash service on a crashed main thread

Below API 29, the app receives the crash service connection on its main
thread. A native crash on the main thread before the daemon attached
froze the app for 10 s, waiting for a daemon that couldn't attach, and
then chained. Don't notify it in that case, so the crash chains at once.
A crash on another thread still waits, since the main thread is free to
attach the daemon.

* fix(android): Don't consume the crash service ready signal

A crash on the main thread checks whether the crash service attached
without the writer lock. A concurrent send could read the ready signal
between the crash handler's poll and read, and the handler then blocked
on the drained pipe. Poll without reading, so that every caller sees the
signal. A reattach replaces the pipe, which drops the old signal.

* test(android): Crash right after init in the e2e test

The e2e fixture crashed 1 s after `SentryAndroid.init`, so no test
covered a crash on the main thread before the crash service connects.
Add an early variant that crashes as soon as the scope is synced. It
runs on API 29 and later, where the service connects on a binder thread
while the crash handler waits.

* test(android): Report an early main-thread crash below API 29

Crash synchronously right after init, so that below API 29 the main
looper cannot connect the crash service first, and relaunch the app
to send the crash.
* feat: Add offline mode to pause uploads

Add sentry_offline_mode_enable/disable/is_enabled. While offline mode
is enabled, nothing is uploaded: envelopes are cached when http_retry
is enabled and discarded otherwise. Disabling it sends the cached
envelopes immediately.

Like user consent, the setting is persisted in the database directory
and loaded by sentry_init before envelopes from previous runs are sent,
so an app that starts while still offline does not try to upload them.
The Crashpad handler and the native crash daemon follow it as well.

Logs and metrics are still discarded while offline, as they are today
while consent is revoked.

Refs #929

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ref: Rename offline mode API to sentry_set_offline/sentry_is_offline

Replace sentry_offline_mode_enable/disable with sentry_set_offline(int)
and sentry_offline_mode_is_enabled with sentry_is_offline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(transport): Don't send queued envelopes while uploads are blocked

Offline mode and user consent are checked when an envelope is
submitted, but envelopes already queued in the HTTP transport were
still sent afterwards. Without connectivity, each of them waited for a
network timeout, so sentry_close() could still hit the shutdown
timeout after sentry_set_offline(1).

Check the upload gate in http_send_task right before sending, and
handle a blocked envelope like a network failure, so the existing
failure path caches it for retry when http_retry is enabled.

Refs #929

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): Apply offline mode before the daemon sends dumped envelopes

The crash daemon submitted the logs, sessions and transactions dumped by
the crashing app before copying user consent and offline mode from
shared memory into its run. With offline mode enabled, those envelopes
were still uploaded (or timed out without connectivity), and with user
consent given, they were held back as if consent was missing.

Copy both values before anything is submitted.

Refs #929

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* fix(native): Enter signal handler state before handling a crash

A crash while the crashed thread holds the macOS malloc lock aborted
the process inside the native crash handler, before the daemon could
send the report:

    _os_unfair_lock_recursive_abort
    _xzm_xzone_malloc_freelist_outlined
    dyld::ThreadLocalVariables::instantiateVariable
    _tlv_get_addr
    sentry__scope_save_active_trace

The scope skips its thread-locals and locks on the thread that entered
the signal handler state. The inproc, breakpad and crashpad handlers
enter it, but the native handler did not.

Ref: getsentry/sentry-cocoa#8271

* fix(scope): Keep thread-local access behind signal handler checks

The first thread-local access on a thread allocates on macOS. Clang
hoisted the inlined `g_scope_access` access above the
`sentry__block_for_signal_handler()` check, so crash handling still
called `_tlv_get_addr` with the malloc lock held:

    _os_unfair_lock_recursive_abort
    _tlv_get_addr
    sentry__scope_save_active_trace

Read the thread-locals through non-inlined accessors that cannot be
hoisted above the check.

Ref: getsentry/sentry-cocoa#8271

* fix: Format numbers with stb_sprintf on Apple platforms

libc `vsnprintf` allocates while formatting doubles, which aborted
crash handling with the malloc lock held:

    _os_unfair_lock_recursive_abort
    __Balloc_D2A
    __dtoa
    sentry__snprintf_c
    sentry__jsonwriter_write_double

Use the stack-only `stbsp_vsnprintf` that Linux already uses.

Ref: getsentry/sentry-cocoa#8271

* test(native): Add a crash test with the allocator locked

`sentry_test_malloc_lock` builds the integration fixture with a
`crash-malloc-locked` scenario, which locks the allocator on a new
thread and crashes there. It locks the default malloc zone on macOS
and the process heap on Windows, and replaces `malloc` with a blocking
version on glibc. Other configurations exit with 77 to skip.

Ref: getsentry/sentry-cocoa#8271

* Update CHANGELOG.md

* test(native): Skip the malloc-locked crash test on Windows

`HeapLock` is recursive for its owner thread, so the crashed thread
could still allocate in the exception filter, and the test could not
catch allocations in the crash handler on Windows. Drop the Windows
lock from the fixture and skip the test there.

Ref: #2336 (comment)
Replace the PR branch ref (getsentry/sentry-java#6614) with the
released 8.66.0 tag so the Android outproc e2e job tests against
a fixed sentry-java release:

- https://github.com/getsentry/sentry-java/releases/tag/8.66.0
* test: Summarize cmake build configurations at -vv

A test that passes an unnecessary CMake option silently misses the
build cache of the integration tests and pays for a full configure and
build. Print a summary at `-vv`, with single-test configurations first:

```text
configurations: 5, tests: 8, time: 33.3s
single-test configurations: 3, time: 19.0s

tests     time  configuration [targets]
    1    10.2s  SENTRY_TRANSPORT=none [sentry]
                tests/test_build.py::test_pkgconfig
    ...
    3     7.9s  SENTRY_BACKEND=breakpad [sentry_test_integration]
    3     6.4s  SENTRY_BACKEND=inproc [sentry_test_integration]
```

Also list all tests per configuration at `-vvv`, move the sccache stats
to `-vv` to keep default output short, and run CI with `-vv`.

* test: Ignore option order in the cmake build cache key

`test_tus_upload` and `test_capture_http` built the same configuration
twice because the key followed the option order.

* test: Share the native build in test_pkgconfig

`native` is the default backend wherever the test runs, but leaving it
implicit built a separate configuration.

* test: Drop the totals from the cmake builds summary

The table rows already show the configurations, and pytest reports the
test counts.
Comment thread src/backends/sentry_backend_native.c Resolved
Comment thread tests/test_e2e_sentry.py Resolved
Comment thread tests/test_integration_native.py Resolved
Comment thread tests/unit/test_cache.c Resolved
Native AOT apps failed to initialize sentry-native in .NET's chiseled
container images:

```text
failed to create database directory or there is no write access to this directory
```

The warning leaves users baffled. They never configured a database
directory, and nothing in the log says which one it means. Here it was
`.sentry-native` in the working directory, the default in both
sentry-native and the .NET SDK, and the apps run as a non-root user in
the root-owned `/app`. The warning now names the directory:

```text
failed to create database directory "/app/.sentry-native" or there is no write access to this directory
```

This matches the `using database path "..."` message that is logged
when the directory can be created.

Ref: getsentry/sentry-dotnet#5999
Comment thread ndk/build.gradle.kts Resolved
Comment thread src/backends/native/sentry_crash_ipc.c Resolved
Comment thread src/backends/sentry_backend_native.c Resolved
Comment thread src/backends/sentry_backend_native.c Resolved
Comment on lines +4539 to +4604
if (minidump_ref) {
add_minidump_ref(envelope, options, minidump_path, run_folder);
}

#if defined(SENTRY_PLATFORM_ANDROID)
sentry_path_t *android_native_envelope_path
= make_run_envelope_path(options->run, envelope);
#endif

SENTRY_DEBUG("Envelope loaded, capturing");

// Launch reporter, or fall back to transport (consent/caching in core).
if (!sentry__launch_external_crash_reporter(options, envelope)) {
if (options && options->transport && options->run) {
SENTRY_DEBUG("Capturing crash envelope");
sentry__capture_envelope(options->transport, envelope, options);
crash_captured = true;
SENTRY_DEBUG("Crash envelope captured (queued)");
} else {
SENTRY_WARN("No transport available for sending envelope");
sentry_envelope_free(envelope);
#if defined(SENTRY_PLATFORM_ANDROID)
// Tombstone merging needs the sentry-java crash service. The
// standalone daemon is only used in tests and is not supported in
// apps, so it handles the envelope as on Linux.
if (daemon && android_native_envelope_path) {
if (!options->run
|| !sentry__run_write_envelope(options->run, envelope)) {
SENTRY_WARN("Failed to dump crash envelope to run folder");
} else {
SENTRY_DEBUG(
"Crash envelope written for Android tombstone merging");
sentry__atomic_store(&ctx->state, SENTRY_CRASH_STATE_DONE);
SENTRY_DEBUG("Released crashed process for Android tombstone");
strncpy(daemon->envelope_path,
android_native_envelope_path->path,
sizeof(daemon->envelope_path) - 1);
daemon->envelope_path[sizeof(daemon->envelope_path) - 1] = '\0';
daemon->event = sentry_value_incref(base);
sentry_envelope_free(envelope);
envelope = NULL;
}
}
#endif
if (envelope) {
if (options->transport && options->run) {
SENTRY_DEBUG("Capturing crash envelope");
if (!sentry__run_should_skip_upload(options->run)) {
*event_id = sentry__envelope_get_event_id(envelope);
}
sentry__capture_envelope(options->transport, envelope, options);
crash_captured = true;
SENTRY_DEBUG("Crash envelope captured (queued)");
} else {
SENTRY_WARN("No transport available for sending envelope");
sentry_envelope_free(envelope);
}
}
} else {
crash_captured = true;
}

#if defined(SENTRY_PLATFORM_ANDROID)
sentry__path_free(android_native_envelope_path);
#endif

// A crash sent via transport keeps its event until the send has finished.
if (run_folder && sentry_uuid_is_nil(event_id)) {
sentry__crash_event_remove(run_folder);
}

// Keep the original crash envelope for the callback on the next launch.
if (!ctx->has_on_crashed_last_run) {
// A crash sent via transport keeps it until the send has finished.
if (!ctx->has_on_crashed_last_run && sentry_uuid_is_nil(event_id)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retained __sentry-crash.envelope lacks large-minidump attachment-ref

With enable_large_attachments, add_minidump_ref only updates the in-memory envelope, but the on-disk __sentry-crash.envelope is kept whenever event_id is set; on_crashed_last_run and interrupted next-launch recovery then read a crash envelope with no minidump and no attachment-ref. Rewrite envelope_path after adding refs, or stop retaining that file when minidump_ref is used.

Evidence
  • minidump_ref forces embedded_minidump to "", so the file written at envelope_path (__sentry-crash.envelope) has no minidump bytes.
  • add_minidump_ref() only mutates the in-memory envelope (materialize + cache sibling + attachment-ref item); nothing in this function rewrites envelope_path.
  • When transport capture sets *event_id, the new guard keeps that on-disk file (!sentry_uuid_is_nil(event_id) skips unlink) and leaves __sentry-event in place.
  • native_backend_process_old_run() reloads __sentry-crash.envelope for on_crashed_last_run and for interrupted recovery (__sentry-event still present), so those paths observe the incomplete envelope.

Identified by Warden · native-code-review · 2JU-W2Y

Comment thread src/backends/sentry_backend_native.c Resolved
Comment on lines 3043 to 3044
NULLIFY_DIR_ENTRY(5, MINIDUMP_STREAM_LINUX_PROC_STATUS);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULLIFY_DIR_ENTRY sets stream_type instead of clearing it

On optional Linux stream failure, NULLIFY_DIR_ENTRY assigns the real stream type with size/rva 0, leaving typed empty directory slots instead of fully zeroed ignored entries; set stream_type to 0 (macro is just above this call).

Evidence
  • Local comments say failed optional entries should end as type/size/rva = 0 so consumers ignore the slot; directories is memset to 0 before stream writes.
  • Optional writers such as write_file_as_stream only fill dir after a successful write_data, so on failure the slot is still all zeros when NULLIFY_DIR_ENTRY runs.
  • The macro sets directories[idx].stream_type = (type) while only zeroing data_size and rva, so the failure path’s only effect is introducing a typed empty entry.
  • macOS sentry__write_minidump clears failed optional slots with stream_type = 0 (and rva/size 0), matching the documented Linux intent.

Identified by Warden · native-code-review · LEV-PGZ

Comment on lines +3887 to +3892
const char *content_type = sentry_value_as_string(content_type_val);

if (path && filename && !attachment_is_placeholder(options, path)) {
write_attachment_to_envelope(
fd, path, filename, attachment_type, content_type);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing attachment content_type written as empty string in crash envelope

sentry_value_as_string() returns "" for non-string/missing keys, so attachments without content_type get content_type:"" in the envelope item header; pass NULL when absent (e.g. sentry__attachment_get_content_type) so write_attachment_to_envelope omits the field.

Evidence
  • sentry_value_as_string() returns "" (never NULL) when the value is not a string (src/sentry_value.c).
  • write_attachment_to_envelope() only omits content_type when the pointer is NULL (if (content_type)), so "" is serialized into the item header.
  • Normal crash attachments from the manifest/IPC list often omit content_type; attachment_list/sentry__write_attachment_manifest only set the key when present.
  • The non-crash path uses sentry__attachment_get_content_type() / value_as_string_or_null and only sets the header when non-NULL (sentry__envelope_add_attachment).

Identified by Warden · native-code-review · TLK-PH3

Comment thread src/sentry_scope.c
Comment on lines +534 to +539
if (sentry_value_is_null(integrations)) {
integrations = sentry_value_new_list();
sentry_value_set_by_key(sdk, "integrations", integrations);
}
sentry_value_append(integrations, sentry_value_new_string(name));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UAF if creating sdk integrations list fails mid-set

When integrations is missing, a successful sentry_value_new_list() followed by a failed sentry_value_set_by_key() frees that list while integrations still aliases it, so the following sentry_value_append() is a use-after-free; re-fetch the list after a successful set or skip append when set fails.

Evidence
  • init_global_scope() does integrations = sentry_value_new_list(); sentry_value_set_by_key(sdk, "integrations", integrations); then always sentry_value_append(integrations, ...).
  • sentry_value_set_by_key() takes ownership of v and sentry_value_decref(v) on failure (e.g. OOM cloning the key or growing the object), freeing the new list.
  • The local integrations value is not cleared or re-read after a failed set, so append reads the freed thing_t.
  • Reachable when get_client_sdk() left no integrations list (SENTRY_BACKEND none/custom, or that set failed) and options has a named integration.

Identified by Warden · native-code-review · ZG7-74P

Comment thread tests/test_integration_crashpad.py Resolved
Comment thread tests/test_integration_native.py Resolved
* ci: run WER tests on Windows

WER ignores crashes in processes that inherit SEM_NOGPFAULTERRORBOX,
which CI runners and other non-interactive parents commonly set. Clear
it in pytest when WER tests are enabled, so that crashing test
processes reach WER.

Enable --with_wer on Windows, disable the WER UI so that a crash dialog
cannot hang a job, and log the runner's error mode and WER
configuration.

* ci: enable diagnostic data for WER

The runner images turn diagnostic data off, which makes WER discard
reports before storing them. Raise AllowTelemetry on the policy keys
so that the WER tests can find their reports.

* test(wer): decode crash output as UTF-8

The output contains the UTF-8 database path, which fails to decode
with the cp1252 locale encoding in UTF-8 path builds and leaves the
captured stdout empty.

* test: skip crashpad WER crash tests on MinGW

The fast-fail, stack buffer overrun, and invalid parameter crashes are
only available in MSVC builds.

* test(wer): declare unvirtualizedResources for the AppX fixture

Windows Server 2022 rejects the manifest without it, because the
mediumIL application and its error reporting extension require the
capability there.

* test(native): expect fast fail for ARM64 heap corruption

ARM64 reports the corrupted heap entry as a fast fail with
FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION instead of raising
STATUS_HEAP_CORRUPTION.

* test: remove outdated WER CI comments

The WER tests now run on CI.

* test(wer): do not run breakpad and crashpad expected failures

Each one builds the backend and waits for a WER report that never
arrives, and the breakpad ones are retried three times via the flaky
marker. Not running them saves several minutes of CI time per Windows
job.

* ci: move WER configuration to a script

Drop the diagnostic logging now that the runner configuration is
known, and avoid New-Item -Force, which clears an existing key.

* ci: pass --with_wer on all platforms

The WER tests skip themselves outside Windows.
Comment thread src/unwinder/sentry_unwinder.c Resolved
Comment thread tests/unit/test_native_backend.c Resolved
Comment thread tests/unit/test_scope.c Resolved
Comment thread tests/unit/test_scope.c Resolved
…#2349)

* fix(native): detect daemon startup failure to avoid 10s stall on Linux

On Linux, a daemon that failed to exec or exited before signaling
ready stalled `sentry_init` until the ready timeout. Watch the message
socket during the wait, which only becomes readable when the daemon
exits.

Ref: getsentry/sentry-dart#3585

* Update CHANGELOG.md

* fix(native): detect daemon startup failure on Windows

A daemon that `CreateProcess` started but that exited before signaling
ready still stalled `sentry_init` until the ready timeout. Keep the
daemon's process handle and wait on it along with the ready event.

Ref: getsentry/sentry-dart#3585
Comment on lines +1339 to +1349
# Give the (out-of-process) handler a moment to write the report.
time.sleep(1)
assert len(httpserver.log) == 0

if sys.platform != "win32":
pending_dir = db_path.joinpath("pending")
completed_dir = db_path.joinpath("completed")
assert pending_dir.exists()
assert len(list(pending_dir.glob("*.dmp"))) >= 1
assert not completed_dir.exists() or not any(completed_dir.glob("*.dmp"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline-mode dump checks use a fixed 1s sleep instead of wait_for_file

After the offline crash, the test sleeps 1s then asserts pending dumps and an empty httpserver log; under ASan or slow CI the handler can take longer, so the pending assert flakes, and the empty-log check can miss a late upload. Use wait_for_file on pending/.dmp (as in test_crashpad_external_crash_reporter_consent_) and/or crashpad-wait-for-upload before asserting no traffic.

Evidence
  • Hunk uses time.sleep(1) then assert len(httpserver.log) == 0 and pending_dir.glob("*.dmp") without polling.
  • Same file already imports wait_for_file and uses assert wait_for_file(pending_dir / "*.dmp") after blocked crashpad crashes (e.g. external reporter consent tests).
  • Those stronger tests also pass crashpad-wait-for-upload so the handler finishes its upload attempt before run() returns; this test does not.
  • Crashpad integration tests are enabled under ASan (has_crashpad only excludes TSan/kcov/valgrind), where a fixed 1s dump wait is short versus wait_for_file's 10s default.

Identified by Warden · native-test-review · ZAV-QT9

Comment thread tests/test_integration_native.py Resolved
Comment thread tests/unit/test_cache.c Resolved
`sentry__parse_cache_filename` also accepts a bare `<uuid>.envelope`
with `attempt = -1`, so `count_cached_envelopes` counted keep-form
names as retry format, and the offline tests would pass if the SDK
wrote the wrong form.

Ref: #2196 (comment)
`sentry_value_as_string` returns an empty string for a missing key, so
the daemon wrote `"content_type": ""` for crash attachments without a
content type. Read it with `sentry__attachment_get_content_type`, which
returns `NULL`, so the item header omits it.

Ref: #2196 (comment)
Comment on lines +442 to +455
if (!sentry__crash_event_remove(run_path)) {
sentry_value_decref(event);
return false;
}

sentry_path_t *path
= sentry__path_join_str(run_path, "__sentry-attachments");
sentry_value_t attachments = sentry__read_attachment_manifest(path);
sentry__path_free(path);
sentry_envelope_t *envelope
= sentry__enclose_event(options, event, NULL, attachments);
sentry_value_decref(attachments);
if (!envelope) {
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crash event is deleted even when envelope construction fails

If envelope allocation or event serialization fails after the event file is removed, this function returns true; old-run processing then deletes the run directory, permanently losing the crash instead of retaining it for retry.

Evidence
  • send_unprocessed_crash() removes __sentry-event before calling sentry__enclose_event().
  • sentry__enclose_event() returns NULL if envelope creation or event addition fails, and its failure path decrefs the event.
  • send_unprocessed_crash() returns true for a NULL envelope. sentry__process_old_runs() then treats the run as processed and removes the run directory.

Identified by Warden · code-review · 3HQ-T64

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Targets 1.0 (v1 branch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.0

5 participants