Skip to content

ref!: sentry_value-based attachments - #1974

Open
jpnurmi wants to merge 3 commits into
jpnurmi/ref/attachments-prepfrom
jpnurmi/ref/attachments
Open

ref!: sentry_value-based attachments#1974
jpnurmi wants to merge 3 commits into
jpnurmi/ref/attachments-prepfrom
jpnurmi/ref/attachments

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Caution

BREAKING CHANGE

Attachment APIs now use sentry_value_t and sentry_uuid_t instead of sentry_attachment_t *.

Scope data is moving to fine-grained read/write locking (#1877) to allow concurrent readers. A read-locked getter cannot safely return a borrowed sentry_attachment_t pointer because a writer may remove and free the attachment as soon as the read lock is released, crashing a potential concurrent reader.

Represent attachments and attachment collections as refcounted sentry_value_t objects. A getter can retain the value under the read lock and return an owned reference that remains valid after unlocking.

Configure attachments before insertion and freeze them once added. Use UUIDs for removal, and retain byte values while envelopes borrow their payload to avoid copying attachment data.

See also:

Resolves: #1945

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.79487% with 176 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.87%. Comparing base (c327cde) to head (4c21efb).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           jpnurmi/ref/attachments-prep    #1974      +/-   ##
================================================================
+ Coverage                         74.67%   74.87%   +0.20%     
================================================================
  Files                               104      104              
  Lines                             26239    26440     +201     
  Branches                           4750     4771      +21     
================================================================
+ Hits                              19593    19798     +205     
+ Misses                             5310     5305       -5     
- Partials                           1336     1337       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 4ecd0c8 to 7cfebae Compare August 11, 2026 20:01
@jpnurmi
jpnurmi changed the base branch from master to jpnurmi/fix/unwinder-arm32-ip August 12, 2026 06:31
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 7cfebae to ed216c7 Compare August 12, 2026 06:33
Comment thread src/sentry_core.c
Comment thread src/sentry_core.c Outdated
Comment thread src/sentry_core.c
Comment thread src/backends/sentry_backend_native.c Outdated
Base automatically changed from jpnurmi/fix/unwinder-arm32-ip to master August 13, 2026 12:47
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 77576ea to 8349c66 Compare August 17, 2026 07:51
Comment thread src/sentry_attachment.c Outdated
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 8349c66 to c7f80db Compare August 17, 2026 09:40
Comment thread src/sentry_core.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from c7f80db to b901758 Compare August 17, 2026 10:37
Comment thread src/backends/sentry_backend_breakpad.cpp
@jpnurmi jpnurmi changed the title [WIP] ref!: sentry_value-based attachments ref!: sentry_value-based attachments Aug 18, 2026
Comment thread src/backends/sentry_backend_crashpad.cpp Outdated
Comment thread src/backends/sentry_backend_crashpad.cpp Outdated

@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 and found 2 potential issues.

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 a6dd4ac. Configure here.

Comment thread src/backends/sentry_backend_crashpad.cpp
Comment thread src/backends/sentry_backend_crashpad.cpp
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 92e0dd1 to 4677c4e Compare August 20, 2026 13:29
Allow callers with borrowed path strings to obtain the final path component
without allocating a sentry_path_t. This prepares value-based attachment
properties, which expose borrowed strings.
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 4677c4e to 4c21efb Compare August 20, 2026 16:26
@jpnurmi
jpnurmi changed the base branch from master to jpnurmi/ref/attachments-prep August 20, 2026 16:30
Comment on lines +945 to +946
= make_attachment_path(options->run->run_path, attachment);
if (!path) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The function native_backend_add_attachment dereferences options->run without a NULL check, which could lead to a crash. A defensive check was removed from the previous implementation.
Severity: LOW

Suggested Fix

Add a defensive NULL check for options->run in native_backend_add_attachment before it is dereferenced at line 945. For example: if (!options || !options->run) { return; }.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/backends/sentry_backend_native.c#L945-L946

Potential issue: In `native_backend_add_attachment`, the code accesses
`options->run->run_path` without verifying that `options->run` is not NULL. While the
standard initialization path via `sentry_init` should ensure `options->run` is
initialized, this is not guaranteed under all conditions. Scenarios such as a failed
`sentry_close()` or a partial backend startup could result in `options->run` being NULL
when `sentry_add_attachment` is invoked. This would cause a NULL pointer dereference and
crash the application. A defensive check for this condition was present in a previous
implementation but has been removed, representing a regression in robustness.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ref(attachments): rework to be sentry_value_t-based

1 participant