-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document potential crashes when using SDK methods from background threads #116
Comments
Hey @RuiAAPeres thanks for submitting this issue; seems like the problem under the hood is that Edit: Probably the suggestion/mitigation might help in most cases of our public API, but if somebody interacts with OpenTelemetry structures directly (like you do in both tests) crashes like this will still happen as those structures are not Thread Safe |
In our app, all interactions with OpenTelemetry are indirectly via the Embrace SDK. The tests above serve as minimum replicable case and just used to narrow down the issue. I would recommend sending an email to your existing customers warning about this situation. It's a pretty serious problem: the SDK used to report crashes is crashing. |
Thank you for taking the time to create the tests; they are really useful for replicating the issue. Obviously, we will be notifying through various channels and updating the documentation/changelog accordingly. That being said, we're somewhat limited in how much we can prevent some of these cases when users directly use Next steps: in the next release, we will be preventing some of these issues, and hopefully, if improvements are also made in OpenTelemetry, we might be able to prevent any type of crash related to concurrency. |
Made a contribution on the OTel repository to fix the issue that's causing this. A more detailed explanation of the underlying problem is on the issue I mentioned before. |
Nice! Thank you. |
SDK version: 6.4.2
Context
The SDK enforces main thread usage for initialization (
setup
andstart
), but other methods likeadd(event:)
and logging don't have the same enforcement despite being unsafe for background thread usage.Issue
While the documentation notes that using the SDK from background threads may lead to data inconsistency, testing shows it can actually cause crashes due to concurrent dictionary access:
This crashes with:
And a more complex test:
The above test can crash in multiple places, which furthers illustrates the problem.
Suggestion
Consider either:
The SDK already has the infrastructure for thread checking (e.g.,
EmbraceSetupError.invalidThread
), it could be extended to other public methods.Mitigation
For other users that might find this issue. I am now enforcing access to the Embrace SDK on the main thread:
The text was updated successfully, but these errors were encountered: