-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
Data races in custom instrumentation (SentrySpan/SentryTracer) and Sentry initialization #3069
Comments
Thanks for reporting this, @everuribe. I fixed one data race for We will look at the other data races and open PRs for them if needed. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This should be fixed in #3303, I'm trying to get it merged today for a new release. |
This was fixed with #3303. Please reopen if you still experience the issue. |
Platform
iOS
Installed
Swift Package Manager
Version
8.5.0, 8.7.3
Steps to Reproduce
There are several observed data races in our app are occurring within Sentry processes.
One obvious instance happens when the app is initialized and
[SentryANRTracker detectANRs]
is called. This happens consistently even when disabling app hang reports so it appears like something that Sentry should fix. Similarly[SentryId empty]
call often shows up as a data race.The remainder of the data races observed are seen in the
SentrySpan
andSentryTracer
API of the framework, specifically in thefinishing
process. There is some overlap of calls trying to access properties of that process (ieisFinished
,wasFinished
,status
and possibly more).We use custom instrumentation where we set up a parent
SentrySpan
for a process that branches out to sub-steps in other modules / threads / contexts for which we establish child spans. We callfinish()
once the span's works is completed, for each span. Eliminating the parent span seems to remove the occurrences of these data races.Tested hypotheses:
SentrySpan
's finishing process should only be externally called once.finish()
had already been called and if so, prevents another call toSentrySpan.finish()
. This did not seem to mitigate the frequency of data races.fatalError
to also make surefinish()
was only called once per span. This also did not seem to have an impact.@TaskLocal
). This did seem to be the case as some times the framework returnsSentryNoOpSpan
when attempting to attach the child. Maybe this causes a weird chain of calls to the finishing process of those spans as the API tries to clean up.SentryNoOpSpan
(checked for emptytraceID
). This also did not have an impact.Expected Result
SentrySpan
/SentryTracer
(unless the API is not supposed to be thread safe?)Actual Result
Our conclusion is that somehow
SentrySpan
andSentryTracer
are not thread safe due to some internal mechanism that calls thefinish
process (maybe related to #3060). We see there is info about not supporting thread safety in the Native framework docs of Sentry but nothing in the Apple docs.Data Races
The text was updated successfully, but these errors were encountered: