realm-core icon indicating copy to clipboard operation
realm-core copied to clipboard

Realm crashes during `deleteRealmIfMigrationNeeded: true` migration

Open ppave opened this issue 1 year ago • 5 comments

How frequently does the bug occur?

5-10 crashes for every 5k users.

Description

Recently I've updated the Realm Swift SDK from 10.7.2 to 10.43.1 and started to see the following crashes that have not seen before. These crashes happen when the app starts and seems like when migration happens.

The following settings are used for migration:

let config = Realm.Configuration(
          fileURL: path,
          schemaVersion: version, // hardcoded value across all schema versions
          migrationBlock: { migration, oldSchemaVersion in 
          },
          deleteRealmIfMigrationNeeded: true
      )
Realm.Configuration.defaultConfiguration = config

Any ideas how to fix/bypass these crashes? Thanks.

Stacktrace & log output

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x7198 __pthread_kill + 8
1  libsystem_pthread.dylib        0xd5f8 pthread_kill + 208
2  libsystem_c.dylib              0x1c4b8 abort + 124
3  Application                    0x1460744 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 148 (terminate.cpp:148)
4  Application                    0x1460984 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 143 (terminate.cpp:143)
5  Application                    0x1460864 realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&) + 156 (terminate.cpp:156)
6  Application                    0x1460758 realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&) + 155 (terminate.cpp:155)
7  Application                   0x11d3980 realm::DB::VersionManager::cleanup_versions(unsigned long long&, std::__1::map<unsigned long long, realm::VersionInfo, std::__1::less<unsigned long long>, std::__1::allocator<std::__1::pair<unsigned long long const, realm::VersionInfo>>>&, bool&) + 81 (initializer_list:81)
8  Application                    0x11d308c realm::DB::low_level_commit(unsigned long long, realm::Transaction&, bool) + 1135 (__tree:1135)
9  Application                    0x11d2f7c realm::DB::do_commit(realm::Transaction&, bool) + 473 (replication.hpp:473)
10 Application                    0x1433588 realm::Transaction::commit_and_continue_as_read(bool) + 264 (transaction.cpp:264)
11 Application                    0x127f2d4 realm::_impl::RealmCoordinator::commit_write(realm::Realm&, bool) + 1423 (vector:1423)
12 Application                    0x12c0c28 realm::Realm::commit_transaction() + 1080 (shared_realm.cpp:1080)
13 Application                    0x10901e0 -[RLMRealm commitWriteTransactionWithoutNotifying:error:] + 648 (RLMRealm.mm:648)
14 Application                    0x1131ba4 Realm.commitWrite(withoutNotifying:) + 332 (Realm.swift:332)
15 Application                    0x1131ac0 Realm.write<A>(withoutNotifying:_:) + 270 (Realm.swift:270)

Can you reproduce the bug?

No

Reproduction Steps

No response

Version

10.43.1

What Atlas Services are you using?

-- select --

Are you using encryption?

No

Platform OS and version(s)

different versions of iOS

Build environment

Xcode version: 15 Dependency manager and version: SPM

ppave avatar Apr 23 '24 11:04 ppave

➤ PM Bot commented:

Jira ticket: RCOCOA-2340

sync-by-unito[bot] avatar Apr 23 '24 11:04 sync-by-unito[bot]

Moved this from Realm-Swift as this seems to be a crash somewhere in Core.

nirinchev avatar Apr 23 '24 11:04 nirinchev

➤ PM Bot commented:

Jira ticket: RCORE-2093

sync-by-unito[bot] avatar Apr 23 '24 11:04 sync-by-unito[bot]

Any updates here? Any advices what can cause it?

ppave avatar Jun 11 '24 07:06 ppave

Sorry for chasing. This issue is quite annoying to me and happens constantly. Could you please help to figure out at least when it happens: during migration, initialisation, usage in several processes, etc? When exactly :VersionManager::cleanup_versions code is called? Thanks in advance.

FYI I've figured out that default.realm.management folder may be removed sometimes in my case and potentially this may cause this issue, Will let you know if that's the case.

ppave avatar Jul 09 '24 09:07 ppave

I confirm that the above problem was caused by removed default.realm.management folder from the file system. Closing this issue.

ppave avatar Aug 04 '24 19:08 ppave