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 on write #6307

Closed
liakhandrii opened this issue Oct 16, 2019 · 2 comments
Closed

Crash on write #6307

liakhandrii opened this issue Oct 16, 2019 · 2 comments

Comments

@liakhandrii
Copy link

Goals

Write an object to Realm.

Expected Results

Object is saved and the app continues working.

Actual Results

The app crashes with this stack trace:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

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

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff6d7c547a __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff6d882707 pthread_kill + 384
2   libsystem_c.dylib             	0x00007fff6d74da08 abort + 120
3   org.cocoapods.Realm           	0x000000010b847099 please_report_this_error_to_help_at_realm_dot_io + 9
4   org.cocoapods.Realm           	0x000000010b84735c realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 140
5   org.cocoapods.Realm           	0x000000010b847516 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 390
6   org.cocoapods.Realm           	0x000000010b6be1da void realm::util::terminate<unsigned long long, int>(char const*, char const*, long, unsigned long long, int) + 58
7   org.cocoapods.Realm           	0x000000010b909fac realm::sync::TableInfoCache::get_table_info(unsigned long) const + 2092
8   org.cocoapods.Realm           	0x000000010b90aafb realm::sync::create_object_with_primary_key(realm::sync::TableInfoCache const&, realm::Table&, realm::util::Optional<long long>) + 43
9   org.cocoapods.Realm           	0x000000010b547738 realm::Object realm::Object::create<objc_object* __strong, RLMAccessorContext>(RLMAccessorContext&, std::__1::shared_ptr<realm::Realm> const&, realm::ObjectSchema const&, objc_object* __strong, bool, bool, unsigned long, realm::BasicRow<realm::Table>*) + 504
10  org.cocoapods.Realm           	0x000000010b54742b RLMAddObjectToRealm + 409
11  andriiliakh.Instant-Translate 	0x000000010af89639 partial apply for closure #3 in HistoryManager.addRecordToHistory(_:json:newServerId:) + 25
12  org.cocoapods.RealmSwift      	0x000000010bdc9328 Realm.write(withoutNotifying:_:) + 56
13  andriiliakh.Instant-Translate 	0x000000010af85163 HistoryManager.addRecordToHistory(_:json:newServerId:) + 6691
14  andriiliakh.Instant-Translate 	0x000000010af8372c HistoryManager.addRecordToHistory(json:) + 172
15  andriiliakh.Instant-Translate 	0x000000010af3fb2e closure #3 in closure #1 in TranslateViewController.translate(autoswap:) + 654
16  andriiliakh.Instant-Translate 	0x000000010aecd7c9 thunk for @escaping @callee_guaranteed () -> () + 25
17  libdispatch.dylib             	0x00007fff6d625553 _dispatch_call_block_and_release + 12
18  libdispatch.dylib             	0x00007fff6d6264de _dispatch_client_callout + 8
19  libdispatch.dylib             	0x00007fff6d631bd3 _dispatch_main_queue_callback_4CF + 1105
20  com.apple.CoreFoundation      	0x00007fff36378290 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
21  com.apple.CoreFoundation      	0x00007fff363779da __CFRunLoopRun + 2370
22  com.apple.CoreFoundation      	0x00007fff36376e13 CFRunLoopRunSpecific + 499
23  com.apple.HIToolbox           	0x00007fff34f03b2d RunCurrentEventLoopInMode + 292
24  com.apple.HIToolbox           	0x00007fff34f0386d ReceiveNextEventCommon + 600
25  com.apple.HIToolbox           	0x00007fff34f035f7 _BlockUntilNextEventMatchingListInModeWithFilter + 64
26  com.apple.AppKit              	0x00007fff33599ac4 _DPSNextEvent + 990
27  com.apple.AppKit              	0x00007fff33598834 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
28  com.apple.AppKit              	0x00007fff33592fd4 -[NSApplication run] + 658
29  com.apple.AppKit              	0x00007fff33584e7d NSApplicationMain + 777
30  andriiliakh.Instant-Translate 	0x000000010aeb4ef9 main + 9
31  libdyld.dylib                 	0x00007fff6d676405 start + 1

Steps to Reproduce

Unknown, happens on a small number of devices. I can't reproduce it on any of ~20 machines I tried.

Code Sample

let newRecord = HistoryRecord()
        
newRecord.timestamp = timestamp
newRecord.sourceLanguage = from
newRecord.targetLanguage = to
newRecord.json = json.rawString() ?? ""
newRecord.serverId = newServerId ?? serverId ?? 0
        
newRecord.text = text
        
do {
    try realm.write {
        realm.add(newRecord)
    }
} catch let error {
    NSLog("\(error)")
}

Model:

class HistoryRecord: Object {
    
    @objc dynamic var json = ""
    @objc dynamic var sourceLanguage = ""
    @objc dynamic var targetLanguage = ""
    @objc dynamic var text = ""
    @objc dynamic var timestamp: Int64 = 0
    @objc dynamic var needsUpdate = false
    @objc dynamic var serverId: Int = 0
    @objc dynamic var isDeleted: Bool = false
    
    override class func primaryKey() -> String? {
        return "timestamp"
    }
}

Version of Realm and Tooling

Realm framework version: 3.19.0

Realm Object Server version: -

Xcode version: 11.1 / 10

iOS/OSX version: 10.15 / 10.14

Dependency manager + version: CocoaPods 1.7.5

@liakhandrii
Copy link
Author

I discovered this is related to #6268

@realm-probot
Copy link

realm-probot bot commented Oct 16, 2019

Hey - looks like you forgot to add a T-* label - could you please add one (if you have access to add labels)?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 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

1 participant