realm-core: Crash - Assertion failed: new_size % (1ULL << m_page_shift) == 0

How frequently does the bug occur?

Always

Description

I’m trying to open a realm-file I have edited with RealmStudio and/or with RealmJava and/or compacted. It leads to the crash/exception below. The file can be properly opened in RealmJava or with RealmStudio. The file is encrypted, but I can provide both file and password via email. This stops me from rolling out updates to my app.

Stacktrace & log output

/Users/realm/workspace/realm_realm-core_release_13.21.0/src/realm/util/encrypted_file_mapping.cpp:1028: [realm-core-13.21.0] Assertion failed: new_size % (1ULL << m_page_shift) == 0
0   Realm                               0x0000000106521868 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   Realm                               0x00000001065217b0 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 400
2   Realm                               0x0000000106521620 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
3   Realm                               0x0000000106506494 _ZNSt3__16vectorIbNS_9allocatorIbEEE6resizeEmb + 0
4   Realm                               0x000000010650e414 _ZN5realm4util24extend_encrypted_mappingEPNS0_20EncryptedFileMappingEPvmmm + 196
5   Realm                               0x000000010650c360 _ZN5realm4util4File7MapBase13try_extend_toEm + 156
6   Realm                               0x000000010638d86c _ZN5realm9SlabAlloc18update_reader_viewEm + 664
7   Realm                               0x000000010638c33c _ZN5realm9SlabAlloc11attach_fileERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_6ConfigEPNS_4util13WriteObserverE + 1024
8   Realm                               0x00000001063c73c0 _ZN5realm2DB4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbRKNS_9DBOptionsE + 1880
9   Realm                               0x00000001063cf814 _ZN5realm2DB6createENSt3__110unique_ptrINS_11ReplicationENS1_14default_deleteIS3_EEEERKNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERKNS_9DBOptionsE + 164
10  Realm                               0x000000010662c10c _ZN5realm5_impl16RealmCoordinator7open_dbEv + 1184
11  Realm                               0x000000010662ce78 _ZN5realm5_impl16RealmCoordinator12do_get_realmEONS_11RealmConfigERNSt3__110shared_ptrINS_5RealmEEENS4_8optionalINS_9VersionIDEEERNS_4util17CheckedUniqueLockEb + 76
12  Realm                               0x000000010662cd68 _ZN5realm5_impl16RealmCoordinator9get_realmENS_11RealmConfigENSt3__18optionalINS_9VersionIDEEE + 460
13  Realm                               0x00000001066bbc98 _ZN5realm5Realm16get_shared_realmENS_11RealmConfigE + 120
14  Realm                               0x00000001062f5dc8 +[RLMRealm realmWithConfiguration:confinedTo:error:] + 892
15  Realm                               0x00000001062f5968 +[RLMRealm realmWithConfiguration:queue:error:] + 156
16  RealmSwift                          0x000000010520eb7c $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 128
17  RealmSwift                          0x00000001052afefc $s10RealmSwift0A0V13configuration5queueA2C13ConfigurationV_So012OS_dispatch_D0CSgtKcfC + 192
18  my-app-name                           0x000000010232cd50 $s9my-app-name7LibraryC7upgrade33_F15A9C9A19EBB745E05E9F5C484B9774LLyyFZ + 3804
19  my-app-name                           0x000000010232bdbc $s9my-app-name7LibraryC7preloadyyFZ + 1172
20  my-app-name                           0x000000010208d82c $s9my-app-name22TrackingViewControllerC10reloadData33_B717444B32E4031AA48693EEE6BC3E5DLLyyFyycfU_ + 312
21  Async                               0x00000001033f9f14 $s5Async0A5BlockV5async33_E687294E1917D2F98ED787A27C7576C6LL5after5block5queueACyytqd__GSdSg_qd__ycAA3GCDAELLOtlFZyycfU_ + 196
22  Async                               0x00000001033f9fe4 $sIeg_IeyB_TR + 48
23  libdispatch.dylib                   0x000000010471329c _dispatch_block_async_invoke2 + 104
24  libdispatch.dylib                   0x0000000104701d5c _dispatch_client_callout + 16
25  libdispatch.dylib                   0x0000000104716ae8 _dispatch_root_queue_drain + 1012
26  libdispatch.dylib                   0x000000010471753c _dispatch_worker_thread2 + 248
27  libsystem_pthread.dylib             0x00000001b059a83c _pthread_wqthread + 224
28  libsystem_pthread.dylib             0x00000001b059963c start_wqthread + 8

Can you reproduce the bug?

Always

Reproduction Steps

Whenever I try to open the file on Mac M1 using Simulator of iPhone 14 Pro running iOS 16.2 via Realm-Swift SDK

Version

10.42.x

What Atlas Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

iOS 16.2 and MacOS 13.4.1 (M1)

Build environment

ProductName:		macOS
ProductVersion:		13.4.1
ProductVersionExtra:	(c)
BuildVersion:		22F770820d

/Applications/Xcode.app/Contents/Developer
Xcode 14.2
Build version 14C18

/opt/homebrew/bin/pod
1.12.1
(not in use here)

/bin/bash
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin22)

carthage not found
(not in use here)

/usr/local/bin/git
git version 2.26.0

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 6
  • Comments: 19 (8 by maintainers)

Most upvoted comments

After debugging with lot of trial and errors I found this bug started from v10.41.1 which has realm-core of 13.17.0 . Culprit should be realm-core. After downgrading swift-realm to 10.41.0 which has realm-core 13.15.1 this crash disappeared. This crash happens only for encrypted db

Thanks @BlueCobold, we’ve received the file and I can reproduce the assertion on open. We will investigate.