-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
2 - S (<= 1 week)
-
2656
What happened?
When I call Realm.GetInstance from my .NET client code normally, it works fine. But if I then run another instance of my application, and call GetInstance, it exits unexpectedly, saying: The program has exited with code -1073740791 (0xc0000409). The Visual Studio debugger does not catch any exceptions or anything, the program just stops, reporting that message to the output.
Best I can find on this exit code is this SO answer which suggests it might be a stack overrun..?
There does seem to be a timing issue involved (maybe with async background threads??) because when I have tried stepping into each instruction, starting from the .GetInstance call, while normally it just exits, on one occasion I actually succeeded in getting a few instructions further - but then it still stopped with the same message a bit later.
(Is this behaviour expected? Is my desired use supported? Should I be doing this another way?)
Repro steps
- App.Create(appId)
- LogInAsync(apiKey)
- Realm.GetInstance(new SyncConfiguration(partition, user))
- <leave application running, start another instance of the same application>
- App.Create(appId)
- LogInAsync(apiKey)
- Realm.GetInstance(new SyncConfiguration(partition, user))
Version
Realm 10.5.1 / .NET 5.0
What SDK flavour are you using?
MongoDB Realm (i.e. Sync, auth, functions)
What type of application is this?
WPF
Client OS and version
Windows 10 Pro 21H1 19043.1237 64-bit operating system, x64-based processor Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz 16.0 GB RAM
Code snippets
private void Window_Loaded(object sender, RoutedEventArgs e) { Action action = async () => await ConnectToRealmAsync(); Dispatcher.BeginInvoke(action, System.Windows.Threading.DispatcherPriority.Background); }
private async Task ConnectToRealmAsync() { RealmStatus = "Connecting";
Session.Error += (sender, errorArgs) =>
{
Debug.WriteLine("Session Error: " + errorArgs.Exception.Message);
RealmStatus = errorArgs.Exception.Message;
};
try { var app = Realms.Sync.App.Create(RealmAppId);
Debug.WriteLine($"app={app}");
var user = await app.LogInAsync(Credentials.ApiKey(RealmApiKey));
Debug.WriteLine($"user={user.Id}"); RealmStatus = "Logged in";
var config = new SyncConfiguration(user.Id, user); var realm = Realm.GetInstance(config); // program exits here before returning to this function, on second instance of application
Debug.WriteLine($"realm={realm}"); RealmStatus = "Ready"; } catch (Exception ex) { Debug.WriteLine("Connection exception: " + ex.Message); RealmStatus = ex.Message; }
}
Stacktrace of the exception/crash you're getting
I wish I had a stacktrace!! All I get is:
The program '[6332] RealmTestApp.exe' has exited with code -1073740791 (0xc0000409).
Relevant log output
app=Realms.Sync.App
user=61345920826942f6487d4d57
The program '[6332] RealmTestApp.exe' has exited with code -1073740791 (0xc0000409).