Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with +[RLMRealm realmWithConfiguration:confinedTo:error:] + 3608 (RLMRealm.mm:433) #8709

Open
doubleyang1988 opened this issue Nov 7, 2024 · 5 comments

Comments

@doubleyang1988
Copy link

How frequently does the bug occur?

Sometimes

Description

After upgrading the compilation to Xcode Version 16.0 (16A242d), I noticed that a couple of my app user is reporting the following crash point from realmDB (10.45.2).

I made very incremental/cautious changes in the previous app release and just upgraded Xcode alone. And this happened with a very small chance but due to the huge installation base, the problem is still collected in the crash report. I have a free threads using the ReamDB concurrently but with different table. Not sure if this would increase the chance the bug is reported.

Stacktrace & log output

0   Realm                         	0x000000010545c624 realm::Exception::what() const + 128
1   Realm                         	0x00000001052e2884 makeError(realm::Exception const&) + 124 (RLMError.mm:188)
2   Realm                         	0x00000001053d8a94 RLMRealmTranslateException(NSError* __autoreleasing*) + 80 (RLMRealm.mm:170)
3   Realm                         	0x00000001053da570 +[RLMRealm realmWithConfiguration:confinedTo:error:] + 3608 (RLMRealm.mm:433)
4   Realm                         	0x00000001053d96dc +[RLMRealm realmWithConfiguration:queue:error:] + 88 (RLMRealm.mm:395)
5   RealmSwift                    	0x0000000105cd109c specialized @nonobjc RLMRealm.__allocating_init(configuration:queue:) + 40 (/<compiler-generated>:0)
6   RealmSwift                    	0x0000000105cd109c @nonobjc RLMRealm.__allocating_init(configuration:queue:) + 40 (/<compiler-generated>:0)
7   RealmSwift                    	0x0000000105cd109c Realm.init(queue:) + 140 (Realm.swift:78)
... Aboove is my source code that tries to use Realm.

Can you reproduce the bug?

Sometimes

Reproduction Steps

No specific steps. As I mentioned, my app have a few threads accessing RealmDB at the same time, but to different databases. Also this issue seemed to only happen after I upgraded the Xcode to Version 16.0 (16A242d)has

Version

10.45.2

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 18.1, iOS 18.0, iOS 17.7, iOS 17.5, iOS 17.4...

Build environment

Xcode version: Xcode Version 16.0 (16A242d)
Dependency manager and version: Cocoapod 1.14.3

Copy link

sync-by-unito bot commented Nov 7, 2024

➤ PM Bot commented:

Jira ticket: RCOCOA-2453

@doubleyang1988
Copy link
Author

Is there any updates on this issue? Also to supplement more information -

  1. The error crashed with:
Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_PROTECTION_FAILURE at XXXXX

So I assume there are some bad memory allocation happened in the SDK.

  1. I checked many core dumps in the app crashes, and found that many of the other threads are doing photo requests (I am doing a photo related App) with the following stack.
0   libsystem_kernel.dylib        	0x00000001db9d1424 kevent_id + 8
1   libdispatch.dylib             	0x000000019ac421bc _dispatch_event_loop_wait_for_ownership + 436 (event_kevent.c:2232)
2   libdispatch.dylib             	0x000000019ac2e594 __DISPATCH_WAIT_FOR_QUEUE__ + 340 (queue.c:1700)
3   libdispatch.dylib             	0x000000019ac2e15c _dispatch_sync_f_slow + 148 (queue.c:1784)
4   CoreData                      	0x000000019aee015c -[NSManagedObjectContext performBlockAndWait:] + 264 (NSManagedObjectContext.m:4102)
5   PhotoLibraryServices          	0x00000001aa9e01f4 -[PLManagedObjectContext _directPerformBlockAndWait:] + 144 (PLManagedObjectContext.m:411)
6   PhotoLibraryServices          	0x00000001aa9e0148 -[PLManagedObjectContext performBlockAndWait:] + 196 (PLManagedObjectContext.m:777)

Unsure if this might cause any race conditions / resource contentions.

Hope these information would be useful, and I am looking for any quick resolution / workaround to stabilize this app. Thanks in advance!

@BlueCobold
Copy link

BlueCobold commented Nov 15, 2024

I know you shouldn't need to, but for me it helped to make sure only one thread at a time is accessing my realm.

Related?
#8708 (comment)
#8692

@doubleyang1988
Copy link
Author

Interesting - I tried to upgrade Realm to v20.0.0 and pushed it to production. Will see if the huge user base can reproduce this issue. From #8692, it seemed the issue was solved by upgrading Realm to 10.54.0. Not sure if the fix was included in 20.0.0, which is just one version before 10.54.0.

@tgoyne
Copy link
Member

tgoyne commented Nov 17, 2024

There shouldn't be any functional differences between v10.54.0 and v20.0.0 other than the sync functionality not being present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants