Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-543

Realm.GetInstanceAsync immediately throws a System.AccessViolationException

      What happened?

      Trying to open a realm database via Realm.GetInstanceAsync immediately throws a System.AccessViolationException

      Repro steps

      Attempt to use Realm.GetInstanceAsync to open a .realm file

      Version

      10.3.0

      What SDK flavour are you using?

      Local Database only

      What type of application is this?

      WPF

      Client OS and version

      Windows 10 Build 19042.1165 Version 20H2

      Code snippets

      private static RealmConfiguration GetConfig(string path)
              {
                  return new RealmConfiguration(path)
                  {
                      ObjectClasses = new[] {
                          typeof(CustomObject1),
                          typeof(CustomObject2),
                          ....
                      },
                      SchemaVersion = SCHEMA_VERSION,
                      MigrationCallback = (migration, oldSchemaVersion) =>
                      {
                          //some custom migration code
                      }
                  };
              }
      
      var realm = await Realm.GetInstanceAsync(GetConfig(path));
      

      Stacktrace of the exception/crash you're getting

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
         at Realms.SharedRealmHandle.NativeMethods.open(Configuration configuration, SchemaObject[] objects, Int32 objects_length, SchemaProperty[] properties, Byte[] encryptionKey, NativeException& ex)
         at Realms.SharedRealmHandle.Open(Configuration configuration, RealmSchema schema, Byte[] encryptionKey) in C:\jenkins\workspace\realm_realm-dotnet_PR-2497\Realm\Realm\Handles\SharedRealmHandle.cs:line 234
         at Realms.RealmConfiguration.CreateRealm(RealmSchema schema) in C:\jenkins\workspace\realm_realm-dotnet_PR-2497\Realm\Realm\Configurations\RealmConfiguration.cs:line 148
         at Realms.RealmConfiguration.<>c__DisplayClass25_0.<CreateRealmAsync>b__0() in C:\jenkins\workspace\realm_realm-dotnet_PR-2497\Realm\Realm\Configurations\RealmConfiguration.cs:line 177
         at System.Threading.Tasks.Task.Execute()
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
         at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
         at System.Threading.ThreadPoolWorkQueue.Dispatch()
      

      Relevant log output

      No response

      Build environment

      Microsoft Visual Studio Community 2022 Preview (64-bit)

            Assignee:
            ferdinando.papale@mongodb.com Ferdinando Papale
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: