Skip to content
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

Deadlock when calling App::current_user from a User listener #7183

Closed
kraenhansen opened this issue Dec 5, 2023 · 0 comments · Fixed by #7186
Closed

Deadlock when calling App::current_user from a User listener #7183

kraenhansen opened this issue Dec 5, 2023 · 0 comments · Fixed by #7186

Comments

@kraenhansen
Copy link
Member

When calling App::current_user from a listener callback registered on a User the thread deadlocks while waiting for the m_user_mutex to release:

std::shared_ptr<SyncUser> SyncManager::get_current_user() const
{
util::CheckedLockGuard lock(m_user_mutex);

But this was already taken by the calling code, here:

std::shared_ptr<SyncUser> SyncManager::get_user(const std::string& user_id, const std::string& refresh_token,
const std::string& access_token, const std::string& device_id)
{
util::CheckedLockGuard lock(m_user_mutex);

This might be related to 64bf842 which was merged 3 months ago and introduced the call to user->log_in:

user->log_in(access_token, refresh_token);

This shows a minimal reproduction in the Realm JS integration tests:

https://github.com/realm/realm-js/blob/f06739da3bcc77dce8e338b1f8960644a33be2c8/integration-tests/tests/src/tests/sync/user-listener-lockup.ts#L31-L43

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant