ref!: sentry_value-based attachments - #1974
Conversation
Codecov Report❌ Patch coverage is 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:
|
4ecd0c8 to
7cfebae
Compare
7cfebae to
ed216c7
Compare
77576ea to
8349c66
Compare
8349c66 to
c7f80db
Compare
c7f80db to
b901758
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
92e0dd1 to
4677c4e
Compare
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.
4677c4e to
4c21efb
Compare
| = make_attachment_path(options->run->run_path, attachment); | ||
| if (!path) { |
There was a problem hiding this comment.
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.

Caution
BREAKING CHANGE
Attachment APIs now use
sentry_value_tandsentry_uuid_tinstead ofsentry_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_tpointer 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_tobjects. 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