Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-2112

Deadlock when calling `App::current_user` from an `App` listener

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Expected results

      Absence of deadlocks.

      Actual Results

      Process locks up waiting for m_user_mutex on https://github.com/realm/realm-core/blob/72fefa1b0c07cb87e1078c039d1d9572dd92fa58/src/realm/object-store/sync/app.cpp#L600 when the current_user is accessed from an "app listener callback".

      Very similar to https://github.com/realm/realm-core/issues/7183 (except this was for User).

      Steps & Code to Reproduce

      The following JS code reproduce the issue:

      import Realm from "realm";
      
      const app = Realm.App.get("realmjstestapp-jjhtf");
      const credentials = Realm.Credentials.anonymous(false);
      
      setInterval(() => {
          console.log("Still alive");
      }, 1000);
      
      app.addListener(() => {
          console.log("Current user is", app.currentUser);
      });
      
      await app.logIn(credentials);
      

      Core version

      Core version: https://github.com/realm/realm-core/commit/8f9661524e3087d9886456d2ce555ea2629eb813 (most likely caused by https://github.com/realm/realm-core/pull/7300)

            Assignee:
            thomas.goyne@mongodb.com Thomas Goyne
            Reporter:
            unitosyncbot Unito Sync Bot
            AD Sync Client
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: