Skip to content

Hub::configure_scope can lose concurrent updates on a shared Hub #1110

@szokeasaurusrex

Description

@szokeasaurusrex

Hub::configure_scope clones the current scope under a read lock, invokes the callback on the clone, then replaces the current scope under a later write lock. Two concurrent calls on the same shared Hub can therefore clone the same initial scope, and the later replacement can discard the earlier mutation.

This is a correctness issue for shared Hub instances: concurrent scope modifications can result in data loss when independent mutations are made to the same shared scope.

Expected behavior: concurrent configure_scope calls on the same Hub should apply mutations atomically with respect to each other, or the API documentation should state that concurrent updates may overwrite each other. One possible fix is to run the scope mutation while holding the write lock, for example through with_current_scope_mut; the implementation should account for the existing constraint that calling scope-related Sentry APIs from inside the callback is unsupported and may panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions