mach_msg_trap()

1. mach_msg() mach_msg_trap()

"

> The Debugger window shows the calling stack at the top of which is

> 0 mach_msg_trap
> 1 mach_msg
> 2 CFRunLoopRunSpecific
> etc.

This is showing the main thread, which is just paused waiting for events. The crash is on a different thread,

but Xcode 3.1 often doesn't switch to the thread that crashed. You'll need to use the thread pop-up to

switch between the different threads to see which one actually has a crash. (Any other threads that are in

mach_msg_trap or in various functions having to do with locks or semaphores are also just idling.) " Ref[10]

2. What's trap?

"Mach system calls are commonly known as "traps", and are maintained in a Mach Trap table. " Ref[9]

3. System Trace

System Trace Profile vs. Time Profiler

"

You can use the System Trace tool in Instruments by running your App in profile mode.

Then you will get a detailed run down of all the threads in the system along with stack traces at each scheduling event the thread goes through.

There is a great video from the 2016 WWDC System Trace in Depth which will walk you through debugging a blocked thread issue.

This is much better than the Time Profiler instrument since, that tool works based off of taking samples of what is running on the CPU at intervals.

However, if your thread is blocked, it isn't running on the CPU, so - it will not be sampled. You might have your main thread blocked for

a whole second but it won't show up in Time Profiler.

" Ref[6]

"

System Trace Profiling Template

Instruments Included in Template

  • Points of Interest

  • System Load

  • Thread State Trace

  • Virtual memory Trace

  • System Call Trace

" Ref[7]


Reference

1. How can main thread be blocked in mach_msg_trap?

http://www.cocoabuilder.com/archive/cocoa/232843-how-can-main-thread-be-blocked-in-mach-msg-trap.html

2. kDebug

2.1 https://www.theiphonewiki.com/wiki/Kdebug

2.2 http://newosxbook.com/tools/kdv.html

2.3 https://www.slideshare.net/JohnPetrucci4/check-point-advanced-kernel-debug

3. Reaching the MACH layer

http://blog.wuntee.sexy/reaching-the-mach-layer

https://github.com/opensource-apple/xnu/

  • Mach messages are sent via kernel traps.

4. mach_msg_trap

https://github.com/apple/darwin-xnu/blob/master/osfmk/mach/mach_traps.h

5. Mach Overview

https://developer.apple.com/library/content/documentation/Darwin/Conceptual/KernelProgramming/Mach/Mach.html#//apple_ref/doc/uid/TP30000905-CH209-TPXREF101

6. iOS How to determine what is blocking the UI

https://stackoverflow.com/questions/15928035/ios-how-to-determine-what-is-blocking-the-ui

7. System Trace Profiling Template

https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/ProfilingTemplates.html#//apple_ref/doc/uid/TP40004652-CH19-SW1

8. macOS MACH Traps

https://sigsegv.pl/osx-mach-traps/

9. Kernel Syscalls

https://www.theiphonewiki.com/wiki/Kernel_Syscalls

10. help-with-debugger-mach-msg-trap-message

http://www.cocoabuilder.com/archive/xcode/279565-help-with-debugger-mach-msg-trap-message.html

11. Core Data Concurrency Debugging

https://oleb.net/blog/2014/06/core-data-concurrency-debugging/

You enable the assertions by passing -com.apple.CoreData.ConcurrencyDebug 1 to your app on the command line via Xcode’s Scheme Editor.

12. Technical Q&A QA1693 Synchronous Networking On The Main Thread

https://developer.apple.com/library/content/qa/qa1693/_index.html

13. System Trace in Depth

https://developer.apple.com/videos/play/wwdc2016/411/

iOS.mach_msg_trap()的更多相关文章

  1. iOS开发-应用崩溃日志揭秘(一)

    作为一名应用开发者,你是否有过如下经历? 为确保你的应用正确无误,在将其提交到应用商店之前,你必定进行了大量的测试工作.它在你的设备上也运行得很好,但是,上了应用商店后,还是有用户抱怨会闪退 ! 如果 ...

  2. iOS测试常见崩溃

    什么是崩溃日志,从哪里能得它? iOS设备上的应用闪退时,操作系统会生成一个崩溃报告,也叫崩溃日志,保存在设备上.崩溃日志上有很多有用的信息,包括应用是什么情况下闪退的.通常,上面有每个正在执行线程的 ...

  3. 【转】iOS应用崩溃日志分析

    作为一名应用开发者,你是否有过如下经历?   为确保你的应用正确无误,在将其提交到应用商店之前,你必定进行了大量的测试工作.它在你的设备上也运行得很好,但是,上了应用商店后,还是有用户抱怨会闪退 ! ...

  4. iOS 深入理解RunLoop

    RunLoop 是 iOS 和 OSX 开发中非常基础的一个概念,这篇文章将从 CFRunLoop 的源码入手,介绍 RunLoop 的概念以及底层实现原理.之后会介绍一下在 iOS 中,苹果是如何利 ...

  5. 苹果官方 Crash文件分析方法 (iOS系统Crash文件分析方法)

    对于提交的苹果官方的app,在审核的时候会给我们一些crash文件,对于这些有用的文件,里面是关于我们的bug的一些信息,那么该如何去调试呢 第一步:在任意目录创建一个目录,用来调试crash,我这里 ...

  6. 【iOS程序启动与运转】- RunLoop个人小结

    学习iOS开发一般都是从UI开始的,从只知道从IB拖控件,到知道怎么在方法里写代码,然后会显示什么样的视图,产生什么样的事件,等等.其实程序从启动开始,一直都是按照苹果封装好的代码运行着,暴露的一些属 ...

  7. 【转】iOS应用崩溃日志揭秘

    这篇文章还可以在这里找到 英语 If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter ...

  8. iOS 事件处理机制与图像渲染过程(转)

    iOS 事件处理机制与图像渲染过程 iOS RunLoop都干了什么 iOS 为什么必须在主线程中操作UI 事件响应 CALayer CADisplayLink 和 NSTimer iOS 渲染过程 ...

  9. iOS开发之Crash分析,以及收集

    一  先谈谈iOS的Crash收集方式: 1. APP 发生crash,用户手机手机上肯定会有crash纪录,当然删除了该app,或是删了再装 crash纪录还是没了. 2. 如果用户设置-隐私  同 ...

随机推荐

  1. 关于No qualifying bean of type [XXX.XXX] found for dependency 的一次记录

    异常开始于spring+springmvc+mybatis 注解配置,启动tomcat服务器出现No qualifying bean of type [com.***.service] found f ...

  2. mysql 5.5数据导入5.7 Failed - Error on Table user - 1067 - Invalid default value for 'CREATE_date'

    表结构是这样 DROP TABLE IF EXISTS `user`;CREATE TABLE `user` (....省略了一些无关紧要的字段 `CREATE_DATE_` timestamp NO ...

  3. ssm注入失败

    今天做ssm整合时候,创建bean/注入一直出错,检查几遍没发现问题,后来发现犯了个低级错误,mapper.xml的<mapper namespace="XXXXX" > ...

  4. 利用pyinstaller生成exe之后,运行不能正常产生结果文件问题记录

    https://segmentfault.com/q/1010000011284617/a-1020000011493026 在此链接已解决问题,现在在这里在详细记录一次 问题描述: 利用pychar ...

  5. JEECG 集成KiSSO单点登录实现统一身份认证

    JEECG 集成KiSSO单点登录实现统一身份认证 JEECG 如何为其他第三方系统实现统一身份认证服务,实现单点登录? 第三方系统如何对接呢? 今天为大家揭开这层面纱,让大家了解实质,使用它更快速的 ...

  6. wcf_first

    WCF包括3部分:client(需要连接到哪里,需要调用什么),service(宿主,及其消息的公开,地址的公开),wcf服务库(提供契约名称,及其怎么干) 步骤: 1.新建wcf库,其中提供一个契约 ...

  7. P1461 海明码 Hamming Codes

    题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B <= 8),使得两两编码之间至少有 D 个单位 ...

  8. P4702 取石子

    我什么时候写一下污污的小故事呢?反正不是现在. 题目描述 Alice 和 Bob 在玩游戏. 他们有 nn 堆石子,第 ii 堆石子有 a_iai​ 个,保证初始时 a_i \leq a_{i + 1 ...

  9. linux随机字符串

    pwgen  -s 32 1 openssl passwd -salt openssl rand -base64 32 openssl rand -hex 100

  10. 【题解】洛谷 P1014 【Cantor表】

    1. 我们先引入三角形数的概念: >定数目的点或圆在等距离的排列下可以形成一个等边三角形,这样的数被称为三角形数. >古希腊著名科学家毕达哥拉斯把数1,3,6,10,15,21……这些数量 ...