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

Specified argument was out of the range of valid values

      What happened?

      Randomly we are getting exception Specified argument was out of the range of valid values and stacktrace is not able to provide the line / code file in our project. It contains only the Realm files .
      Full stack trace is given below

      Unhandled Exception from source=AppDomain
      System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
      Parameter name: Get from RealmResults index: 1 beyond range of: 1
        at Realms.NativeException.ThrowIfNecessary () [0x00009] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Native\NativeException.cs:77 
        at Realms.ResultsHandle.GetValueAtIndex (System.Int32 index, Realms.Realm realm) [0x00016] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Handles\ResultsHandle.cs:121 
        at Realms.RealmResults`1[T].GetValueAtIndex (System.Int32 index) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResults.cs:79 
        at Realms.RealmCollectionBase`1[T].get_Item (System.Int32 index) [0x0000f] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:138 
        at Realms.RealmCollectionBase`1+<>c__DisplayClass48_0[T].<OnChange>b__1 (System.Int32 i) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:313 
        at System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].ToList () [0x00040] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/Select.cs:759 
        at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:30 
        at Realms.RealmCollectionBase`1[T].TryGetConsecutive (System.Int32[] indices, System.Func`2[T,TResult] getter, System.Collections.IList& items, System.Int32& startIndex) [0x0001f] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:370 
        at Realms.RealmCollectionBase`1[T].OnChange (Realms.IRealmCollection`1[T] sender, Realms.ChangeSet change) [0x001ab] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:313 
        at Realms.NotificationCallbacks`1[T].Notify (Realms.ChangeSet changes, System.Boolean shallow) [0x0004c] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:673 
        at Realms.RealmCollectionBase`1[T].Realms.INotifiable<Realms.NotifiableObjectHandleBase.CollectionChangeSet>.NotifyCallbacks (System.Nullable`1[T] changes, System.Boolean shallow) [0x0012b] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:415 
        at Realms.NotifiableObjectHandleBase.NotifyObjectChanged (System.IntPtr managedHandle, System.IntPtr changes, System.Boolean shallow) [0x00017] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Handles\NotifiableObjectHandleBase.cs:61 
        at (wrapper native-to-managed) Realms.NotifiableObjectHandleBase.NotifyObjectChanged(intptr,intptr,int)
        at (wrapper managed-to-native) Realms.SynchronizationContextScheduler.scheduler_invoke_function(intptr,bool)
        at Realms.SynchronizationContextScheduler+Scheduler.<Post>b__5_0 (System.Object f_ptr) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Native\SynchronizationContextScheduler.cs:82 
        at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 
        at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
        at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-31/mcw/Java.Lang.IRunnable.cs:84 
        at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 
        at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr)
      

      Repro steps

      1. Create models with some back links and implement IRealmObject interface
      2. Subscribe for the changes
      3. Try to add/delete/select items from the model created in step 1
      4. For few cases, randomly this exception comes. It's kind of sporadic issue.

      Version

      .Net Standard 2.1

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Xamarin

      Client OS and version

      Windows 10 / Android 13

      Code snippets

      Unable to find the exact code form where this exception is coming. Randomly this is coming. In Visual Studio even if we turn on all exceptions then also it is not throwing the except in our lines of code.
      Also we have subscribed the Realm().Error += (s, e) =>{} but it is not coming in this method also.

      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 from source=AppDomain
      System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
      Parameter name: Get from RealmResults index: 1 beyond range of: 1
        at Realms.NativeException.ThrowIfNecessary () [0x00009] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Native\NativeException.cs:77 
        at Realms.ResultsHandle.GetValueAtIndex (System.Int32 index, Realms.Realm realm) [0x00016] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Handles\ResultsHandle.cs:121 
        at Realms.RealmResults`1[T].GetValueAtIndex (System.Int32 index) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResults.cs:79 
        at Realms.RealmCollectionBase`1[T].get_Item (System.Int32 index) [0x0000f] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:138 
        at Realms.RealmCollectionBase`1+<>c__DisplayClass48_0[T].<OnChange>b__1 (System.Int32 i) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:313 
        at System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].ToList () [0x00040] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/Select.cs:759 
        at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:30 
        at Realms.RealmCollectionBase`1[T].TryGetConsecutive (System.Int32[] indices, System.Func`2[T,TResult] getter, System.Collections.IList& items, System.Int32& startIndex) [0x0001f] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:370 
        at Realms.RealmCollectionBase`1[T].OnChange (Realms.IRealmCollection`1[T] sender, Realms.ChangeSet change) [0x001ab] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:313 
        at Realms.NotificationCallbacks`1[T].Notify (Realms.ChangeSet changes, System.Boolean shallow) [0x0004c] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:673 
        at Realms.RealmCollectionBase`1[T].Realms.INotifiable<Realms.NotifiableObjectHandleBase.CollectionChangeSet>.NotifyCallbacks (System.Nullable`1[T] changes, System.Boolean shallow) [0x0012b] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:415 
        at Realms.NotifiableObjectHandleBase.NotifyObjectChanged (System.IntPtr managedHandle, System.IntPtr changes, System.Boolean shallow) [0x00017] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Handles\NotifiableObjectHandleBase.cs:61 
        at (wrapper native-to-managed) Realms.NotifiableObjectHandleBase.NotifyObjectChanged(intptr,intptr,int)
        at (wrapper managed-to-native) Realms.SynchronizationContextScheduler.scheduler_invoke_function(intptr,bool)
        at Realms.SynchronizationContextScheduler+Scheduler.<Post>b__5_0 (System.Object f_ptr) [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Native\SynchronizationContextScheduler.cs:82 
        at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 
        at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
        at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-31/mcw/Java.Lang.IRunnable.cs:84 
        at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V callback, System.IntPtr jnienv, System.IntPtr klazz) [0x00005] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 
        at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr)
      

      Relevant log output

      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
      Not available
      

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: