Skip to content

ref(value)!: atomic decref result check#1763

Open
jpnurmi wants to merge 4 commits into
masterfrom
jpnurmi/ref/refcount
Open

ref(value)!: atomic decref result check#1763
jpnurmi wants to merge 4 commits into
masterfrom
jpnurmi/ref/refcount

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 27, 2026

Note

SC/BC break (low impact)

Fixes TOCTOU races in sentry__transaction_context_free, sentry__transaction_decref and sentry__span_decref by adding return value for sentry_value_decref indicating whether the value still has references, has been freed, or is primitive that needs no tracking:

if (!sentry_value_decref(value)) {
  free(related_resources);
}

While taking the BC/SC break hit, make sentry_value_incref return the incref'd value for convenience, to avoid reducing such boilerplate:

// before
sentry_value_incref(value);
do_something(value);

// after
do_something(sentry_value_incref(value));

@jpnurmi jpnurmi force-pushed the jpnurmi/ref/refcount branch from 1f48fb6 to 654a646 Compare May 27, 2026 11:18
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.

1 participant