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

iOS14.1.0 Crash:RLMAddObjectToRealm #6919

Closed
enze0923 opened this issue Nov 9, 2020 · 5 comments
Closed

iOS14.1.0 Crash:RLMAddObjectToRealm #6919

enze0923 opened this issue Nov 9, 2020 · 5 comments

Comments

@enze0923
Copy link

enze0923 commented Nov 9, 2020

Unfortunately I was able to reproduce it once. Crashlytics is showing this for a few users.

Goals
Fix the crash

Expected Results
The app not crashing

Actual Results

Fatal Exception: RLMException
0  CoreFoundation                 0x18deee5ac __exceptionPreprocess
1  libobjc.A.dylib                0x1a1fdc42c objc_exception_throw
2  Readict                        0x1033283ac RLMAddObjectToRealm + 158 (RLMObjectStore.mm:158)
3  Readict                        0x102e82b0c closure #1 in DNRealmDBManager.saveBook(bookModel:readTime:joinBookSelf:manuly:) + 88 (RDTRealmDBManager.swift:88)
4  Readict                        0x10340c9dc Realm.write(withoutNotifying:_:) + 213 (Realm.swift:213)
5  Readict                        0x102e82768 DNRealmDBManager.saveBook(bookModel:readTime:joinBookSelf:manuly:) + 76 (RDTRealmDBManager.swift:76)
6  Readict                        0x102de4e70 specialized SSFReadStartViewController.pauseSaveOperation(bookModel:readPageCount:allWordCounts:isJoinLibrary:chapterIndex:allWordsThisReading:) + 13 (RDTUserManager.swift:13)
7  Readict                        0x102ddbb40 SSFReadStartViewController.readEngineDidDisappear(_:bookModel:readPageCount:allWordCounts:) + 17 (RDTRealmDBManager.swift:17)
8  Readict                        0x102d3a568 SSFReadEngine.viewDidDisappear(_:) (<compiler-generated>)
9  Readict                        0x102d3a624 @objc SSFReadEngine.viewDidDisappear(_:) (<compiler-generated>)
10 UIKitCore                      0x19011af20 -[UIViewController _setViewAppearState:isAnimating:]
11 UIKitCore                      0x19011bcbc -[UIViewController __viewDidDisappear:]
12 UIKitCore                      0x19004f1b0 -[UINavigationController viewDidDisappear:]
13 UIKitCore                      0x19011af20 -[UIViewController _setViewAppearState:isAnimating:]
14 UIKitCore                      0x19011bcbc -[UIViewController __viewDidDisappear:]
15 UIKitCore                      0x19002420c -[UITabBarController viewDidDisappear:]
16 UIKitCore                      0x19011af20 -[UIViewController _setViewAppearState:isAnimating:]
17 UIKitCore                      0x19011bcbc -[UIViewController __viewDidDisappear:]
18 UIKitCore                      0x19011bdd4 -[UIViewController _endAppearanceTransition:]
19 UIKitCore                      0x18ffffa24 __48-[UIPresentationController transitionDidFinish:]_block_invoke
20 UIKitCore                      0x18ffff764 -[UIPresentationController transitionDidFinish:]
21 UIKitCore                      0x190009be8 -[_UICurrentContextPresentationController transitionDidFinish:]
22 UIKitCore                      0x190003ecc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.528
23 UIKitCore                      0x19013f134 -[_UIViewControllerTransitionContext completeTransition:]
24 UIKitCore                      0x190cfee54 -[UITransitionView notifyDidCompleteTransition:]
25 UIKitCore                      0x190cfeb00 -[UITransitionView _didCompleteTransition:]
26 UIKitCore                      0x190d3589c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
27 UIKitCore                      0x190d08b3c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
28 UIKitCore                      0x190d09070 -[UIViewAnimationState animationDidStop:finished:]
29 UIKitCore                      0x190d091d4 -[UIViewAnimationState animationDidStop:finished:]
30 QuartzCore                     0x191262d58 CA::Layer::run_animation_callbacks(void*)
31 libdispatch.dylib              0x18daecac8 _dispatch_client_callout
32 libdispatch.dylib              0x18dafa04c _dispatch_main_queue_callback_4CF
33 CoreFoundation                 0x18de6b1e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
34 CoreFoundation                 0x18de653b4 __CFRunLoopRun
35 CoreFoundation                 0x18de644bc CFRunLoopRunSpecific
36 GraphicsServices               0x1a4976820 GSEventRunModal
37 UIKitCore                      0x190811164 -[UIApplication _run]
38 UIKitCore                      0x190816840 UIApplicationMain
39 Readict                        0x102ca7488 main + 14 (main.m:14)
40 libdyld.dylib                  0x18db2be40 start

Steps to Reproduce
I can't reproduce it but it is happening in production (Firebase Crashlytics)

Code Sample

public func saveBook(bookModel: RDTBookShelfModel, readTime: Int = 0, joinBookSelf: Bool = false, manuly: Bool = true) {
        if let realm = getRealmDB() {
            do {
                try realm.write {
                    bookModel.latestReadDate = Date()
                    bookModel.readingTime += readTime
                    if joinBookSelf, !bookModel.isJoinBookSelf {
                        bookModel.isJoinBookSelf = true
                        bookModel.isUserManulyJoinBookSelf = manuly
                        bookModel.joinBookSelfTime = Date()
                        bookModel.libraryOpen = false
                        UserDefaults.standard.set(true, forKey: RDT_Library_Alert_Can_Show)//library可以展示show
                    }
                    bookModel.readedChpaters.append(objectsIn: bookModel.operationReadedChpaters)
                    realm.add(bookModel, update: .modified)
                }
            } catch let error{
                print("Unexpected error: \(error.localizedDescription).")
            }
        }
    }

Version of Realm and Tooling
RealmSwift framework version: 3.19.1

Realm Object Server version: Not using

Xcode version: 12.1

iOS/OSX version: 14.1.0

@pavel-ship-it
Copy link
Contributor

Hi @enze0923
Could you please try to update Realm to the latest version?

@enze0923
Copy link
Author

Okay, i will update to the latest version first. Thanks!

Hi @enze0923
Could you please try to update Realm to the latest version?

@enze0923
Copy link
Author

I update RealmSwift to 10.1.2,and i still encountered the same crash.
extra crash info: crash_info_entry_0 failure to grow array

0
CoreFoundation
-[__NSArrayM insertObject:atIndex:].cold.2 + 16
1
CoreFoundation
-[__NSArrayM removeObjectsInRange:] + 1082
2
Readict
RLMArray.mm - Line 187
changeArray(RLMArray*, NSKeyValueChange, unsigned long, void () block_pointer) + 187
3
Readict
RLMArray.mm - Line 266
-[RLMArray insertObject:atIndex:] + 266
4
Readict
RLMArray.mm - Line 80
-[RLMArray addObject:] + 80
5
Readict
- Line 157812
List.append(objectsIn:) + 157812
6
Readict
- Line 4310100752
closure #1 in DNRealmDBManager.saveBook(bookModel:readTime:joinBookSelf:manuly:) + 4310100752
7
Readict
- Line 4311580816
thunk for @callee_guaranteed () -> (@error @owned Error) + 4311580816
8
Readict
- Line 4310117576
partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) + 4310117576
9
Readict
thunk for @callee_guaranteed () -> (@error @owned Error)partial apply + 4310118540
10
Readict
Realm.swift - Line 255
Realm.write(withoutNotifying::) + 255
11
Readict
RDTRealmDBManager.swift - Line 76
DNRealmDBManager.saveBook(bookModel:readTime:joinBookSelf:manuly:) + 76
12
Readict
RDTUserManager.swift - Line 15
specialized SSFReadStartViewController.pauseSaveOperation(bookModel:readPageCount:allWordCounts:isJoinLibrary:chapterIndex:allWordsThisReading:) + 15
13
Readict
RDTRealmDBManager.swift - Line 17
SSFReadStartViewController.readEngineDidDisappear(
:bookModel:readPageCount:allWordCounts:) + 17
14
Readict
- Line 4308708952
SSFReadEngine.viewDidDisappear(_:) + 4308708952

@pavel-ship-it
Copy link
Contributor

Do you have any information on that faulty device? Low free memory?
Also could you share a model of the suspicious data base object? How you declare bookModel?
The second crash looks kinda interesting as it happens in __NSArrayM.
Any information on the length of that array?
What is the typical size of bookModel object?

@leemaguire
Copy link
Contributor

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@sync-by-unito sync-by-unito bot closed this as completed Nov 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants