Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-821

Multiple EXC_BAD_ACCESS Crashes

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      Have my app run normally without crashes.

      Expected Results

      Same as "Goals" (above).

      Actual Results

      I'm seeing EXC_BAD_ACCESS in at least 2 different places. Please see:-

      This might be related to #6556, but since that has been closed for a while, I decided to open a new issue for this.

      Steps for others to Reproduce

      So far, I have been unable to reproduce this in a sample project, but, here are a few things I can tell:-

      • Crash occurs randomly during a mass import when several write transactions are committed in quick succession on a single serial operation queue.
      • This happens on brand new installation (i.e. not upgrading from old file format, also, not following compaction).
      • My realm is stored in shared app group container (if that matters).
      • So far, I have been unable to reproduce this on the Simulator, but it occurs fairly frequently when running on an actual device (iPad 6th generation).
      • Since one of the crashes happens in do_encryption_read_barrier, I think it's also worth mentioning that my Realm is not encrypted.
      • I have noticed that I can get rid of this crash if is slow down my writes (since my writes are committed on a serial background queue using NSOperation subclasses, adding [NSThread sleepForTimeInterval:1.0]; after [realm commitWriteTransaction]; in my NSOperation subclass is enough, but this is obviously not ideal). I eventually hit this crash irrespective on this change.
      • One way that I have found to get rid of these crashes is to not use realm notifications of any kind, or use KVO on realm objects. (Which is also not ideal).
      • A pattern I have noticed: This crash manifests itself after I have crashed once with a "mmap() failed: Cannot allocate memory size: XXXXXXXX offset: 0" exception during a mass import upon a fresh install, after which there are only EXC_BAD_ACCESS crashes no "mmap() failed" exceptions. I must say though: the exact same code had absolutely no "mmap() failed" exceptions or EXC_BAD_ACCESS crashes when used with realm-cocoa version 4.3.2.

      Code Sample

      <!---
      Provide a code sample or test case that highlights the issue.
      If relevant, include your model definitions.
      For larger code samples, links to external gists/repositories are preferred.
      Alternatively share confidentially via mail to help@realm.io.
      Full Xcode projects that we can compile ourselves are ideal!
      -->
      None right now.

      Version of Realm and Tooling

      <!---
      In the CONTRIBUTING guidelines, you will find a script,
      which will help determining some of these versions.
      -->
      Realm framework version: 5.3.5

      Realm Object Server version: N/A

      Xcode version: 12 Beta 6

      iOS/OSX version: iOS 14 Beta 6

      Dependency manager + version: SPM (or Dynamic Framework built from source)

            Assignee:
            jason.flax@mongodb.com Jason Flax
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: