崩溃日志显示没有发生的调用堆栈

时间:2018-06-08 05:09:49

标签: ios swift realm

.crash文件的部分

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x000000018181d2ec __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001819be288 pthread_kill$VARIANT$mp + 376 (pthread.c:1484)
2   libsystem_c.dylib               0x000000018178bd0c abort + 140 (abort.c:91)
3   libc++abi.dylib                 0x0000000180f272c8 abort_message + 132 (abort_message.cpp:75)
4   libc++abi.dylib                 0x0000000180f27470 default_terminate_handler() + 304 (cxa_default_handlers.cpp:68)
5   libobjc.A.dylib                 0x0000000180f508d4 _objc_terminate() + 124 (objc-exception.mm:657)
6   libc++abi.dylib                 0x0000000180f4137c std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:66)
7   libc++abi.dylib                 0x0000000180f40ccc __cxa_throw + 132 (cxa_exception.cpp:130)
8   libobjc.A.dylib                 0x0000000180f50720 objc_exception_throw + 364 (objc-exception.mm:547)
9   Realm                           0x00000001029405f0 -[RLMRealm verifyThread] + 80 (RLMRealm.mm:152)
10  Realm                           0x00000001028c8a78 invocation function for block in objc_object* (anonymous namespace)::makeBoxedGetter<realm::StringData>(unsigned long) + 80 (RLMObject_Private.hpp:47)
11  My App                  0x00000001025ab94c CallerDetailViewController.getTitleOfCaller() + 64 (CallerDetailViewController.swift:1864)
12  My App                  0x00000001025b4db8 specialized CallerDetailViewController.displayUnableToMarkAsNotSpamErrorMessage(error:) + 48
13  My App                  0x00000001025b5684 specialized closure #2 in closure #2 in CallerDetailViewController.blockNumber() + 100 (CallerDetailViewController.swift:0)
14  My App                  0x00000001025b809c partial apply for closure #2 in closure #2 in CallerDetailViewController.blockNumber() + 176 (CallerDetailViewController.swift:0)
15  My App                  0x0000000102629b7c thunk for @callee_owned () -> () + 36 (Toast.swift:0)
16  libdispatch.dylib               0x0000000181688aa0 _dispatch_call_block_and_release + 24 (init.c:994)

然而,这个堆栈跟踪是在应用程序中不会发生的 - 方法blockNumber()不调用方法displayUnableToMarkAsNotSpamErrorMessage(),也不调用任何方法(也没有任何混合等)继续)。崩溃堆栈如何显示一个不存在的方法调用堆栈?

func blockNumber()
{
    Model.log("CallerDetailViewController:blockNumber()")
    if editActionIsInProgress == true
    {
        return
    }
    var op : UsageStats.Op = UsageStats.Op("IOS-VZ-UI-\(self.VCNAME)-BLOCKEXISTING")
    let mdnToBlock = self.caller!.number
    editActionIsInProgress = true
    RootNavigationController.displayActivityIndicator(message: NSLocalizedString("VC_CALLER_DETAIL_BLOCKING_IN_PROGRESS", comment: ""))
    if isExistingCaller
    {
        Model.instance().robocallerManager().blockExistingCaller(mdn: mdnToBlock) {(error) -> Void in
            Model.log("CallerDetailViewController:blocExistingCaller() completion")
            self.editActionIsInProgress = false
            RootNavigationController.hideActivityIndicator  { () in
                DispatchQueue.main.async {
                    if error == nil
                    {
                        self.displayBlockedConfirmationMessage()
                        self.displayGUIBasedOnCategory()
                    }
                    else
                    {
                        let err = error! as NSError
                        self.displayUnableToUnblockErrorMessage(error: err)
                        let _ = op.withError(error!)
                    }
                    UsageStats.collectUIStatistics(op)
                }
            }
        }
    }
    else
    {
        let mdn = caller?.number
        var op : UsageStats.Op = UsageStats.Op("IOS-VZ-UI-\(self.VCNAME)-BLOCKNEW")

        // disable the block button in the popup until the operation has completed to prevent user's from
        // tapping it twice
        Model.instance().robocallerManager().blockNewCaller(caller: caller!, completion: { (error) in
            Model.log("CallerDetailViewController:blockNewCaller() completion")
            self.editActionIsInProgress = false
            RootNavigationController.hideActivityIndicator(completion: {})
            DispatchQueue.main.async {
                if error == nil
                {
                    // Fetch the newly added Realm managed object within the main thread to ensure the realm is the one for the main thread
                    self.caller = Model.instance().database().findCaller(mdn: mdn!)
                    self.isExistingCaller = true
                    self.addRealmNotification()
                    self.displayBlockedConfirmationMessage()
                    self.displayGUIBasedOnCategory()
                }
                else
                {
                    let err = error! as NSError
                    self.displayUnableToUnblockErrorMessage(error: err)
                    let _ = op.withError(error!)
                }
                UsageStats.collectUIStatistics(op)
            }
        })
    }
}


func displayUnableToMarkAsNotSpamErrorMessage(error:Swift.Error)
{
    var message = self.getTitleOfCaller()
    message = message + " - " + (self.caller?.number.formatPhoneNumberForDisplay())! + " " + NSLocalizedString("VC_CALLER_DETAIL_UNABLE_TO_MARK_AS_NOT_SPAM", comment: "")
    RootNavigationController.displayErrorDialog(title: message, err: error as NSError)
}

2 个答案:

答案 0 :(得分:0)

我实际上不认为正在呼叫CallerDetailViewController.displayUnableToMarkAsNotSpamErrorMessage。您会注意到在堆栈跟踪中其放置的末尾没有符号执行行。

我有一些猜测,这里可能会发生什么,但是如果没有真正查看您的代码或不了解这些方法中的任何实际含义,我无法肯定为什么它会出现在堆栈跟踪中。< / p>

答案 1 :(得分:-1)

根据您的崩溃日志, CallerDetailViewController 类的 getTitleOfCaller 函数中的代码导致崩溃。 RLMRealm的 verifyThread 函数中发生崩溃的事实告诉我,您正在尝试访问其他线程上的领域对象。在Realm中这是不允许的,因为对象是线程限制的。

您可以签出Realm’s documentation on how to fix this.