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

Crash on IOS with NativeAOT: help interpreting a stacktrace

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      What happened?

      After navigating to a certain page in our app on IOS, (which requires loading something from Realm), and idling for 20 to 30mins, we get a crash.

      Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
      Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000016ce53a28
      Exception Codes: 0x0000000000000002, 0x000000016ce53a28
      VM Region Info: 0x16ce53a28 is in 0x16ce50000-0x16ce54000;  bytes after start: 14888  bytes before end: 1495
            REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
            mapped file              13ada0000-13b0d4000 [ 3280K] r--/rw- SM=COW  ...t_id=894c3ea7
            GAP OF 0x31d7c000 BYTES
      --->  STACK GUARD              16ce50000-16ce54000 [   16K] ---/rwx SM=NUL  ... for thread 0
            Stack                    16ce54000-16cf50000 [ 1008K] rw-/rwx SM=SHM  thread 0
      Termination Reason: SIGNAL 11 Segmentation fault: 11
      Terminating Process: exc handler [6083]
      
      Triggered by Thread:  0
      

      Stacktrace below.

      Initially we would like help in understanding this stacktrace so that we can try to locate where things are going wrong and whether this is a realm issue or a dotnet/macios issue.

      • INumberBase.Parse is being called, perhaps on a UInt64.
        • Why would there be a conversion from a utf8 span to UInt64 (or any other number type)? Are any numbers stored in Realm as char spans rather than binary-encoded? We don't have any uint64 types in our codebase so perhaps this is an internal realm type?
        • I assume this is initially triggered by some GC (realm gc, or dotnet gc?). Some GC could trigger some realm methods to be run - that is possible?
      • The 10Mathematics_EduTypes_RQLRecord is not a realm type. Realm types know about it via static or instance methods and these are involved in conversion from Realm types to out types, but these types shouldn't be involved in Realm database operations themselves. We are unsure why this type is in the stacktrace.
      • At the start of the stacktrace, there is a GC crash. Presumably some native memory management is off.

      Repro steps

      Get out IOS app from testflight. Navigate to a certain page. Wait 20-30mins. The app crashes.

      Version

      dotnet8-ios NativeAOT

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Xamarin

      Client OS and version

      iPad12,1

      Code snippets

      No response

      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
      WKS::GCHeap::GarbageCollectGeneration(unsigned int, gc_reason) (in 50iOS) (gc.cpp:50552)
      WKS::gc_heap::allocate_in_older_generation(WKS::generation*, unsigned long, int, unsigned char*) (in 50iOS) (gc.cpp:19828)
      WKS::gc_heap::allocate_in_expanded_heap(WKS::generation*, unsigned long, int&, unsigned char*, int, WKS::mark*, int, int) (in 50iOS) (gc.cpp:20294)
      WKS::gc_heap::exponential_smoothing(int, unsigned long, unsigned long) (in 50iOS) (gc.cpp:22237)
      WKS::GCHeap::DiagWalkHeap(bool (*)(Object*, void*), void*, int, bool) (in 50iOS) (gc.cpp:52062)
      RhpCreateTypeManager (in 50iOS) (RuntimeInstance.cpp:271)
      SystemNative_EnumerateGatewayAddressesForInterface (in 50iOS) (pal_interfaceaddresses.c:604)
      fram0_System_Text_RegularExpressions_System_Text_RegularExpressions_Symbolic_SymbolicRegexMatcher_1<UInt64>__FindEndPositionDeltas<System_Text_RegularExpressions_System_Text_RegularExpressions_Symbolic_SymbolicRegexMatcher_1_DfaStateHandler<UInt64>__System_Text_RegularExpressions_System_Text_RegularExpressions_Symbolic_SymbolicRegexMatcher_1_NoZAnchorInputReader<UInt64>__System_Text_RegularExpressions_System_Text_RegularExpressions_Symbolic_SymbolicRegexMatcher_1_InitialStateFindOptimizationsHandler<UInt64>__System_Text_RegularExpressions_System_Text_RegularExpressions_Symbolic_SymbolicRegexMatcher_1_FullNullabilityHandler<UInt64>> (in 50iOS) + 644
      fram0_System_Linq_System_Linq_Enumerable_SelectIListIterator_2<S_P_CoreLib_System_Collections_Generic_KeyValuePair_2<Int8__System___Canon>___10Mathematics_EduTypes_RQLRecord>__Clone (in 50iOS) + 4
      fram0_System_Linq_System_Linq_Enumerable_SelectIListIterator_2<S_P_CoreLib_System_Collections_Generic_KeyValuePair_2<Int8__System___Canon>___10Mathematics_EduTypes_RQLRecord>__MoveNext (in 50iOS) + 136
      fram0_Realm_Realms_RealmCollectionBase_1<S_P_CoreLib_System_Nullable_1<Single>>___ctor (in 50iOS) (D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:155)
      fram0_S_P_CoreLib_System_Numerics_INumberBase_1<System___Canon>__System_IUtf8SpanParsable_TSelf__Parse (in 50iOS) + 52
      

            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:
              Resolved: