CoreAnalytics::Client / FrameworkConfiguration::init 内部的神秘崩溃

Posted

技术标签:

【中文标题】CoreAnalytics::Client / FrameworkConfiguration::init 内部的神秘崩溃【英文标题】:Mysterious crash inside CoreAnalytics::Client / FrameworkConfiguration::init 【发布时间】:2020-09-08 20:04:19 【问题描述】:

我遇到了一个难以调试的奇怪崩溃。我可以在启动我的应用程序后立即触发它,只需按下并释放命令键几次;不需要与我的应用程序进行其他交互。不用说,当命令键改变状态时,我的应用程序不会做任何事情。实际上,其他按键也会触发崩溃,包括字母键; Command 没有什么特别之处,只是它似乎不太可能有其他副作用。

崩溃总是在后台线程中,总是带有相同的回溯,其中不包含我的任何代码:

#0  0x00007fff603da3ec in __cxa_throw ()
#1  0x00007fff42e90492 in nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::parser::unexpect(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::lexer::token_type) const ()
#2  0x00007fff42e8ccad in nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::parser::parse_internal(bool) ()
#3  0x00007fff42e8fe63 in nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::parser::parse() ()
#4  0x00007fff42e8fcd4 in nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::parse<char const*, 0>(char const*, char const*, std::__1::function<bool (int, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>::parse_event_t, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer>&)>) ()
#5  0x00007fff42e826be in FrameworkConfiguration::init() ()
#6  0x00007fff42e82478 in FrameworkConfiguration::create(applesauce::xpc::object) ()
#7  0x00007fff42e82100 in CoreAnalytics::Client::handleConfigurationChange_sync(applesauce::xpc::dict const&) ()
#8  0x00007fff42e81f52 in CoreAnalytics::Client::handleServerMessage_sync(applesauce::xpc::dict) ()
#9  0x00007fff42e94039 in ___ZZN13CoreAnalytics6Client4initEvENK3$_1clEv_block_invoke ()
#10 0x00007fff634b8a54 in _xpc_connection_call_event_handler ()
#11 0x00007fff634b795c in _xpc_connection_mach_event ()
#12 0x000000010040482f in _dispatch_client_callout4 ()
#13 0x0000000100421b3a in _dispatch_mach_msg_invoke ()
#14 0x000000010040bb40 in _dispatch_lane_serial_drain ()
#15 0x0000000100422eda in _dispatch_mach_invoke ()
#16 0x000000010040bb40 in _dispatch_lane_serial_drain ()
#17 0x000000010040cae8 in _dispatch_lane_invoke ()
#18 0x0000000100419f2e in _dispatch_workloop_worker_thread ()
#19 0x000000010049002c in _pthread_wqthread ()
#20 0x000000010048f157 in start_wqthread ()

nlohmann:: stuff 是一个我认识的 JSON 库,因为我在其他项目中使用过它,但我没有在这个项目中使用它。根据 Google 的说法,FrameworkConfiguration:: 和 CoreAnalytics:: 与我无法直接控制的 Apple 内部分析收集垃圾有关。我已经关闭了这台机器上系统偏好设置中的所有分析,在安全和隐私面板中,然后重新启动机器;该错误仍然是 100% 可重现的。

发生这种情况时,应用程序中的主线程什么也不做;通常它位于 mach_msg_trap() 中。主线程上的回溯也没有我的代码,并且是空闲的 CFRunLoop 的典型 macOS 回溯。

我尝试打开 Xcode 提供的各种调试功能——地址清理器、未定义行为清理器、malloc scribble / 保护边缘 / 保护 malloc / 僵尸对象 / malloc 堆栈。这些都不会导致与问题相关的任何输出。 (即,除了 malloc 内容的初始输出说它已启用之外,没有任何输出,等等等等。)

我使用的是 Catalina 10.15.3、Xcode 11.3.1。我的下一步将是升级这两个;我忘记了我已经过时了,但只是有点过时了,所以如果这有什么不同,那就太令人惊讶了。

显然,当我按下按键时,我系统上的其他应用程序不会崩溃,所以我的应用程序正在做的事情一定会触发这个问题,但我无法想象是什么,我不知道如何调试这个。我想如果升级没有帮助,我会复制我的项目并开始删除大块代码,直到错误不再重现,并尝试缩小应用程序的责任部分。不过,我想我会先在这里查看是否有人看过。谢谢。


补充:我刚刚更新到 macOS 10.15.4 和 Xcode 11.4.1。这次崩溃没有变化。是时候开始雕刻了。如果我找出原因,我会在这里发布,以便其他人找到他们是否击中这个。

【问题讨论】:

“但我没有在这个项目中使用它” 不,Apple 使用它。它似乎正在崩溃。整个事情似乎是苹果的错误。举报!如果这是可重现的,那正是他们所需要的;将应用程序包含在报告中。这不是堆栈溢出问题。 感谢 Eyeballs 和 Jiggler。还有大脚。派对就像 1990 年一样! Ben - 好吧,没有实际代码,我们无能为力。恐怕我的策略会和你的一样,也就是我所说的米开朗基罗调试(去掉所有看起来不像大卫的东西)。 我看到这个问题是没有 cmets 的 downvotes 的目标。请不要那样做。这是一个有效的问题,另一个人(上面)说他们遇到了同样的问题,我找到了一个解决方案,我在下面的答案中发布了该解决方案。这就是 Stack Overflow 的用途。如果您不这么认为,请至少留下评论,说明您为什么认为在 Stack Overflow 上分享这些有用的知识是不好的。 我在同一个框架中遇到了一个可能相关的问题,请参阅here。而且我认为,IS 是 Stack Overflow 的问题,只要不清楚原因是什么。 【参考方案1】:

嗯,有点不满意的答案是它似乎是某种损坏的 Xcode 项目文件的结果。我从 11.4.1 中创建的一个新的 Cocoa 应用项目开始,并在源文件和资源中一一添加,边做边测试。我最终重新创建了完整的项目,并且该错误不再存在。通过遵循所有 Xcode 的项目升级建议,旧的 Xcode 项目是从旧版本继承而来的。我已经用细齿梳检查了这两个项目的所有构建设置,但看不到任何可以解释差异的东西。这是一个谜。但为了后代:如果您发现此问题,请从头开始重建您的项目。

【讨论】:

【参考方案2】:

对我来说,这也不是一个深层次的问题。

解决方法是删除设备上的应用程序版本(这是我刚刚注册的新设备,已经加载了应用程序的 App Store 版本)。

我也做了“清理构建文件夹”,但下一次运行,Apple 的 CoreAnalytics 没有抛出任何异常,这显然有一个错误。

【讨论】:

以上是关于CoreAnalytics::Client / FrameworkConfiguration::init 内部的神秘崩溃的主要内容,如果未能解决你的问题,请参考以下文章

斐波那契数列性质

如何求解:f(n) = f(n-1) + 3*f(n-2) + 3*f(n-3) + f(n-4)

C# 练习用函数递归计算 f(n)=f(n-1)+f(n-2) f=2 f=3

C# 练习用函数递归计算 f(n)=f(n-1)+f(n-2) f=2 f=3

C# 练习用函数递归计算 f(n)=f(n-1)+f(n-2) f=2 f=3

C# 练习用函数递归计算 f(n)=f(n-1)+f(n-2) f=2 f=3