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

Crash when read-only Realm is querying objects in an extension while read-write Realm from main application is committing transactions

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      How frequently does the bug occur?

      Always

      Description

      I have a user who sporadically reports crashes when trying to share items using the sharing extension.

      The strange thing is that most of the times it works correctly, but other times it fails 2-3 times in a row and then continues to work correctly.

      I've traced the code and the crashes happen when I'm trying to retrieve all objects of a certain type from from the database via realm.objects(ClassName.self). This happened with two separate classes.

      Stacktrace & 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
      First crash log:
      
      OS Version: iOS 16.6 (20G75)
      Report Version: 104
      
      Exception Type: EXC_CRASH (SIGABRT)
      Crashed Thread: 10
      
      Application Specific Information:
      Assertion failed: has_refs()
      
      Thread 10 Crashed:
      0   libsystem_kernel.dylib          0x3ac59b578         __pthread_kill
      1   libsystem_pthread.dylib         0x3ee291114         pthread_kill
      2   libsystem_c.dylib               0x33d05b174         abort
      3   Realm                           0x102573cfc         please_report_this_issue_in_github_realm_realm_core_v_13_17_1
      4   Realm                           0x102574030         realm::util::terminate_internal
      5   Realm                           0x102573ea0         realm::util::terminate_with_info
      6   Realm                           0x102573d10         realm::util::terminate
      7   Realm                           0x10242a7e8         realm::Group::validate_top_array
      8   Realm                           0x1024286b0         realm::Group::attach
      9   Realm                           0x10254787c         realm::Transaction::Transaction
      10  Realm                           0x10240e9c4         (anonymous namespace)::make_transaction_ref<T>
      11  Realm                           0x102408eb8         realm::DB::start_read
      12  Realm                           0x10271b4d0         realm::Realm::begin_read
      13  Realm                           0x10271b3c8         realm::Realm::transaction
      14  Realm                           0x1027b39d4         RLMClassInfo::table (RLMClassInfo.mm:52)
      15  Realm                           0x1027e1cb0         RLMGetObjects (RLMObjectStore.mm:201)
      16  RealmSwift                      0x102137840         Realm.objects<T> (Realm.swift:762)
      
      
      
      Second crash log:
      
      OS Version: iOS 16.6 (20G75)
      Report Version: 104
      
      Exception Type: EXC_CRASH (SIGABRT)
      Crashed Thread: 1
      
      Application Specific Information:
      Assertion failed: has_refs()
      
      Thread 1 Crashed:
      0   libsystem_kernel.dylib          0x3ac59b578         __pthread_kill
      1   libsystem_pthread.dylib         0x3ee291114         pthread_kill
      2   libsystem_c.dylib               0x33d05b174         abort
      3   Realm                           0x101e1fcfc         please_report_this_issue_in_github_realm_realm_core_v_13_17_1
      4   Realm                           0x101e20030         realm::util::terminate_internal
      5   Realm                           0x101e1fea0         realm::util::terminate_with_info
      6   Realm                           0x101e1fd10         realm::util::terminate
      7   Realm                           0x101cd67e8         realm::Group::validate_top_array
      8   Realm                           0x101cd46b0         realm::Group::attach
      9   Realm                           0x101df387c         realm::Transaction::Transaction
      10  Realm                           0x101cba9c4         (anonymous namespace)::make_transaction_ref<T>
      11  Realm                           0x101cb4eb8         realm::DB::start_read
      12  Realm                           0x101fc74d0         realm::Realm::begin_read
      13  Realm                           0x101fc73c8         realm::Realm::transaction
      14  Realm                           0x10205f9d4         RLMClassInfo::table (RLMClassInfo.mm:52)
      15  Realm                           0x10208dcb0         RLMGetObjects (RLMObjectStore.mm:201)
      16  RealmSwift                      0x1019e3840         Realm.objects<T> (Realm.swift:762)
      

      Can you reproduce the bug?

      Sometimes

      Reproduction Steps

      Unfortunately I can't provide the Realm file that causes this as it contains confidential user data.

      The relevant code that I use is this:

      var config = Realm.Configuration(    
          fileURL: realmFilePath,
          schemaVersion: latestSchemaVersion,
          migrationBlock: migrationBlock
      )
      
      config.encryptionKey = encryptionKey
      config.readOnly = true
      
      let realm = try! Realm(configuration: config)
      
      results = realm
          .objects(SVContact.self)
          .sorted(byKeyPath: sortProperty)
      

      SVContact is a Realm Object.

      Version

      v10.42.0

      What Atlas Services are you using?

      Local Database only

      Are you using encryption?

      Yes

      Platform OS and version(s)

      iOS 16.6

      Build environment

      Xcode version: 14.3.1
      Dependency manager and version: Carthage 0.39.0

            Assignee:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: