RUM-11821: Fix crash in KronosTimeProvider#3014
Merged
aleksandr-gringauz merged 7 commits intoNov 20, 2025
Merged
Conversation
ba267f4 to
effd411
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3014 +/- ##
===========================================
+ Coverage 71.16% 71.23% +0.07%
===========================================
Files 859 859
Lines 31429 31444 +15
Branches 5298 5302 +4
===========================================
+ Hits 22364 22396 +32
+ Misses 7565 7550 -15
+ Partials 1500 1498 -2
🚀 New features to boost your workflow:
|
effd411 to
4148140
Compare
0xnm
previously approved these changes
Nov 20, 2025
| }.onFailure { ex -> | ||
| internalLogger.log( | ||
| level = InternalLogger.Level.WARN, | ||
| targets = listOf(InternalLogger.Target.MAINTAINER, InternalLogger.Target.TELEMETRY), |
Member
There was a problem hiding this comment.
I'm a bit afraid that adding TELEMETRY target here may cause a recursion loop. Yes, we have onlyOnce = true, but can you double-check that no time info is gathered between log call is made and onlyOnce check is actually hit?
Contributor
Author
There was a problem hiding this comment.
Thanks for mentioning it, I haven't thought about this situation.
I checked that:
- Yes, recursion indeed happens because here when
DatadogContextis being created it callstimeProvider.getServerTimestamp. - But
onlyOncehelps, I observe that this line gets executed when the logging is called on the second iteration of "recursion".
So looks like everything is fine here.
jonathanmos
previously approved these changes
Nov 20, 2025
ambushwork
previously approved these changes
Nov 20, 2025
c7127b2
|
🎯 Code Coverage 🔗 Commit SHA: 7cffdcd | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
0xnm
previously approved these changes
Nov 20, 2025
jonathanmos
previously approved these changes
Nov 20, 2025
0xnm
approved these changes
Nov 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
See the ticket for a stacktrace.
I haven't managed to determine how widespread this crash is, I can't find it in the list of crashes on google play console, I only can see it through the link shared by a single customer though google play console.
I haven't managed to reproduce it either.
The crash happens most likely because (it is the most plausible explanation I can come up with):
kronosClock.shutdownhere.kronosClock.getCurrentTimeMsis called as a result of this call tosdkCore.time.deviceTimeNs.ensureServiceIsRunningcall throwsIllegalStateExceptionhere.sdkCore.time.deviceTimeNscan get the oldtimeProvider, after thatkronosClock.shutdownis called on another thread and finallysdkCore.time.deviceTimeNsinteracts with this clock using the old 'timeProvider`.This PR does the following:
Add try/catch in
KronosTimeProviderso that it becomes physically impossible to crash if by some reason we interact with an already shutdown kronos clock.We could make
timeProvidervolatile. But it will not help with the point 4.sdkCore.time.deviceTimeNsis not "atomic", clock can be shut down at any point during execution of this code, so the best we can do is try/catch.Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)