realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.21k stars 2.14k forks source link

Cannot reproduce crash on RLMAccessor.makeSetter #5495

Closed bupojung closed 6 years ago

bupojung commented 6 years ago

Crash Description

crash in write block to change a property of reaml object like this: if let m = Mail.mail(with: ss.mailID) { StoreManager.shared.write { if summary.length > 0 { m.summary = summary } } }

write function in Storemanager

func write( block:()->()) { do{ try myRealm?.safeWrite { block() } } catch let error as NSError { logError("Realm Write Error:\(error.localizedDescription)") } }

safeWrite function

extension Realm { public func safeWrite(_ block: (() throws -> Void)) throws { if isInWriteTransaction { try block() } else { try write(block) } } }

Crash Log

Incident Identifier: E9877C7A-697B-4231-92C7-2F3CE087BDAD CrashReporter Key: c9f7ab890cc723196d0625ca33e4a20bfb198909 Hardware Model: iPhone9,1 Process: XMail [617] Path: /private/var/containers/Bundle/Application/EEB863FA-EB50-4BC5-A81A-D236C75FB0A5/XMail.app/XMail Identifier: com.xvipMobile.XMail Version: 10 (1.1.0) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.xvipMobile.XMail [551]

Date/Time: 2017-11-30 10:05:07.8219 +0800 Launch Time: 2017-11-30 10:00:55.2349 +0800 OS Version: iPhone OS 10.3.1 (14E304) Report Version: 104

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0

Application Specific Information: abort() called

Filtered syslog: None found

Last Exception Backtrace: 0 CoreFoundation 0x184e02fd8 exceptionPreprocess + 124 1 libobjc.A.dylib 0x183864538 objc_exception_throw + 56 2 Realm 0x1009499a0 _ZZZN12_GLOBALN_110makeSetterIU8__strongP8NSStringS3_EEP11objc_objectP11RLMPropertyEUb1_ENKUlvE_clEv + 317856 (RLMAccessor.mm:0) 3 Realm 0x10094988c invocation function for block in objcobject (anonymous namespace)::makeSetter<NSString strong, NSString* strong>(RLMProperty*) + 317580 (RLMAccessor.mm:308) 4 XMail 0x10010e910 closure #1 in closure #1 in ServerMailCellModel.saveSummary(:) + 846096 (ServerMailCellModel.swift:107) 5 XMail 0x1000a19a4 partial apply for closure #1 in StoreManager.write(block:) + 399780 (StoreManager.swift:0) 6 RealmSwift 0x100fb018c Realm.write(:) + 147852 (Realm.swift:155) 7 XMail 0x10009ff5c specialized StoreManager.write(block:) + 393052 (StoreManager.swift:272) 8 XMail 0x10010e794 closure #1 in ServerMailCellModel.saveSummary(:) + 845716 (ServerMailCellModel.swift:111) 9 RxSwift 0x10132bee4 AnonymousObservable.run(:cancel:) + 229092 (Create.swift:60) 10 RxSwift 0x10135f8e4 Producer.subscribe(:) + 440548 (Producer.swift:18) 11 RxSwift 0x101353e34 ObserveOnSerialDispatchQueue.run(:cancel:) + 392756 (ObserveOn.swift:219) 12 RxSwift 0x10135f8e4 Producer.subscribe(:) + 440548 (Producer.swift:18) 13 RxSwift 0x10135136c protocol witness for ObservableType.subscribe(_:) in conformance Observable + 381804 (Observable.swift:0) 14 RxSwift 0x101383f20 closure #1 in SubscribeOnSink.run() + 589600 (SubscribeOn.swift:58) 15 RxSwift 0x101389584 thunk for @calleeowned () -> (@out Disposable) + 611716 (Take.swift:0) 16 RxSwift 0x10132b3e8 ConcurrentMainScheduler.schedule(:action:) + 226280 (ConcurrentMainScheduler.swift:48) 17 RxSwift 0x10132b6e0 protocol witness for ImmediateSchedulerType.schedule(:action:) in conformance ConcurrentMainScheduler + 227040 (ConcurrentMainScheduler.swift:0) 18 RxSwift 0x101383e44 SubscribeOnSink.run() + 589380 (SubscribeOn.swift:61) 19 RxSwift 0x1013845f4 SubscribeOn.run(:cancel:) + 591348 (SubscribeOn.swift:80) 20 RxSwift 0x10135fe38 closure #1 in Producer.subscribe(:) + 441912 (Producer.swift:26) 21 RxSwift 0x10132c604 specialized CurrentThreadScheduler.schedule(:action:) + 230916 (CurrentThreadScheduler.swift:99) 22 RxSwift 0x10135fa30 Producer.subscribe(:) + 440880 (Producer.swift:30) 23 RxSwift 0x10134c174 specialized MergeSink.subscribeInner(:) + 360820 (Merge.swift:507) 24 RxSwift 0x10134ac68 MergeSink.on(:) + 355432 (Merge.swift:489) 25 RxSwift 0x10134b7f4 protocol witness for ObserverType.on(:) in conformance <A, B, C> MergeSink<A, B, C> + 358388 (Merge.swift:0) 26 RxSwift 0x10137e594 Sink.forwardOn(:) + 566676 (Sink.swift:35) 27 RxSwift 0x10134b55c MergeSinkIter.on(:) + 357724 (Merge.swift:424) 28 RxSwift 0x10134b6d4 protocol witness for ObserverType.on(:) in conformance <A, B, C> MergeSinkIter<A, B, C> + 358100 (Merge.swift:0) 29 RxSwift 0x10137e594 Sink.forwardOn(:) + 566676 (Sink.swift:35) 30 RxSwift 0x10132bc38 AnonymousObservableSink.on(:) + 228408 (Create.swift:50) 31 RxSwift 0x10132bdc8 protocol witness for ObserverType.on(:) in conformance AnonymousObservableSink + 228808 (Create.swift:0) 32 RxSwift 0x101354b90 partial apply + 396176 (ObserverType.swift:0) 33 RxSwift 0x1012fc420 AnyObserver.on(:) + 33824 (AnyObserver.swift:39) 34 RxSwift 0x1012fc490 protocol witness for ObserverType.on(:) in conformance AnyObserver + 33936 (AnyObserver.swift:0) 35 RxSwift 0x10135498c ObserverType.onNext(_:) + 395660 (ObserverType.swift:27) 36 XMail 0x100079328 specialized closure #1 in closure #1 in IMAPManager.fetchMessageHTMLBody(IMAPMsg:folder:) + 234280 (IMAPManager.swift:555) 37 XMail 0x10007b74c partial apply for closure #1 in closure #1 in IMAPManager.fetchMessageHTMLBody(IMAPMsg:folder:) + 243532 (IMAPManager.swift:0) 38 XMail 0x10006f998 thunk for @callee_owned (@owned String?, @owned Error?) -> () + 194968 (IMAPManager.swift:0) 39 XMail 0x1002cba8c -[MCOIMAPMessageRenderingOperation operationCompleted] + 207 40 XMail 0x1002b81f8 -[MCOOperation _operationCompleted] + 39 41 libdispatch.dylib 0x183cba9a0 _dispatch_client_callout + 16 42 libdispatch.dylib 0x183ccb7a8 _dispatch_barrier_sync_f_slow_invoke + 304 43 libdispatch.dylib 0x183cba9a0 _dispatch_client_callout + 16 44 libdispatch.dylib 0x183cbf5e8 _dispatch_main_queue_callback_4CF + 996 45 CoreFoundation 0x184db10c0 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 46 CoreFoundation 0x184daecdc __CFRunLoopRun + 1572 47 CoreFoundation 0x184cded94 CFRunLoopRunSpecific + 424 48 GraphicsServices 0x186748074 GSEventRunModal + 100 49 UIKit 0x18af97130 UIApplicationMain + 208 50 XMail 0x1000537b8 main + 79800 (AppDelegate.swift:13) 51 libdyld.dylib 0x183ced59c start + 4

Steps to Reproduce

can not reproduce

Version of Realm and Tooling

Realm framework version: 2.10.2

Realm Object Server version: 2.10.2

Xcode version: 9.1 Build version 9B55

iOS/OSX version: iPhone OS 10.3.1 (14E304)

bupojung commented 6 years ago

I found this may happen when the String property is too long.

austinzheng commented 6 years ago

Would you be willing to make a reproduction case? When you say "String property is too long", do you mean storing a very long string in a string-typed property, and if so how long was the string?

bupojung commented 6 years ago

I have try to reproduce using long String, but cannot reproduce the case. I use bugly to collect crash log. And this is tips bugly give me: `

0 Thread

RLMException String too big`

bupojung commented 6 years ago

wechatimg47

bdash commented 6 years ago

That exception is raised if you attempt to store a string larger than 16MB in size. This size limit is called out in the Current Limitations section of our documentation.

bupojung commented 6 years ago

Thanks bdash.

ashif-ismail commented 5 years ago

i have also get this error sometimes,im pretty much sure that in no way i will be storing more than 16mb for a property..

infact i'm just saving textual data...

any suggestions ?