-
Notifications
You must be signed in to change notification settings - Fork 168
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
Assertion failure: m_state == SyncUser::State::LoggedIn
in sync_user.cpp:315
#5571
Comments
For some extra context, I don't believe it's particularly easy to trigger that crash - one really has to try or be very unlucky. So it's not the highest priority in the world, but probably a good idea to audit the relevant code and make sure it's free of race conditions. |
Can we prioritize fixing this or is there a workaround we can apply for our tests? We're seeing this show up more and more often on CI. I don't believe we've made changes to C# code exercising this codepath, so not sure why it's happening more often. |
➤ Jonathan Reams commented: Sure, we can think of a workaround. This was put on the backlog because it was going to be resolved by a larger project, but if this is happening more frequently then we can come up with a work-around or fix it in the short-term. How frequently is this happening - once a week or once a day? |
➤ nirinchev commented: It's happening on pretty much all of our CI runs when we merge to main. There we test on 6 platforms and at least one will always fail, sometimes more. So I'd say 15-20% of the time. |
➤ Jonathan Reams commented: Okay, [~[email protected]] will take a look. I've bumped up the priority in the meantime. |
SDK and version
SDK : .NET
Core Version: 12.1.0
Observations
Crash log / stacktrace
Steps & Code to Reproduce
Looking at the code in the stacktrace, I don't believe this assertion is correct or at least the code preceding the call to
User::update_identities
is correct.When
App:log_in_with_credentials
is called, we obtain a user that is in LoggedIn state. However, by the time the request inApp::get_profile
completes, there's no guarantee that the user hasn't logged out/been removed. We do callUser::set_state(SyncUser::State::LoggedIn)
but that's after we callupdate_identities
:realm-core/src/realm/object-store/sync/app.cpp
Lines 487 to 489 in 51a64fe
Since we're not holding a mutex on the user while manipulating their identities and state, I don't think these assertions make sense. A logout call can race with any of these operations, resulting in an assertion failure. Instead I'd suggest that we either take a lock on the user while updating their information (and move the
set_state
call first) or we replace the assertions with if-checks that make the method a no-op for logged out users.The text was updated successfully, but these errors were encountered: