realm-swift: [Xcode 15] iOS 14.5 crashing with Realm 10.42.3
How frequently does the bug occur?
Always
Description
After building the app with Xcode 15 and Realm 10.42.3 (using SPM), it crashes immediately while starting it in the simulator with Thread 1: EXC_BAD_ACCESS (code=1, address=0x0).
Xcode shows the following for this thread:
When building and running the app with Xcode 14.3.1 (14E300c) and also Realm 10.42.3, there isn’t any crash.
Stacktrace & log output
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [49668]
Triggered by Thread: 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 0x0 ???
1 App 0x104f29f1c _GLOBAL__sub_I_RLMApp.mm + 28
2 dyld_sim 0x10e641f54 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 424
3 dyld_sim 0x10e64231c ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 52
4 dyld_sim 0x10e63ca40 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 448
5 dyld_sim 0x10e63ac78 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 184
6 dyld_sim 0x10e63ad40 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 92
7 dyld_sim 0x10e62e33c dyld::initializeMainExecutable() + 216
8 dyld_sim 0x10e632d88 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 4440
9 dyld 0x10e887d88 dyld4::prepareSim(dyld4::RuntimeState&, char const*) + 1328
10 dyld 0x10e88664c dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 276
11 dyld 0x10e885e18 start + 1964
Thread 1:
0 libsystem_pthread.dylib 0x1bca3f634 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x1bca3f634 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x1bca3f634 start_wqthread + 0
Can you reproduce the bug?
Always
Reproduction Steps
It crashes always during app start.
Version
10.42.3
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
iOS 14.5
Build environment
Xcode version: 15.0 (15A240d) Dependency manager and version: SPM
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 2
- Comments: 27 (3 by maintainers)
I managed to resolve this issue after implementing the workaround method (Adding the
-Wl,-ld_classicoptions to theOTHER_LDFLAGSbuild in the project settings). Tried initialising basic Realm project on iOS 14.5 simulator.If you are using RealmSwift via Cocoapods,
-Wl,-ld_classicoptions must also be added to theOTHER_LDFLAGSin the Pods’s project setting as well.Just found how to solve the issue on iOS 12.
In addition to the -Wl, -ld_classic flags, go to Build Phases > Link Binary With Libraries, add SwiftUI and set it to Optional.
Also, be careful, there is an error in Realm latest changelog (-classic_ld instead of -ld_classic)
As noted above you need to pass
-Wl,-ld_classicbecause the new linker does not support iOS <15.Also having the crashes on Realm initialization since xCode 15. Used Realm 10.38.0, but updating to 10.42.3 didn’t resolve it – using Cocoapods.
Crashes on initialization on both iOS 12 and iOS 14 (physical devices)
We have reports of this issue from users with iOS 12.5.
I don’t know, I don’t have a device running iOS 14
Same issue here.
I’ve created a new project and just added Realm with SPM. It crashes on iOS 12 (device) and iOS 14 (simulator).
Could it be related to this known issue with Xcode 15 new Linker ? (I tried the workaround but no luck)