Understanding iOS Exception Types

iOS 稳定性问题治理:卡死崩溃监控原理及最佳实践 在这里小编整理了一份Android大厂常见面试题,和一些Android架构视频解析,都已整理成文档,全部都已打包好了,希望能够对大家有所帮助,在面试中能顺利通过。喜欢本文的话,不妨顺手给我点个小赞、评论区留言或者转发支持一下呗《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!有帮助,可以扫码获取!!(备注:Android)** 阅读详情

When your iOS app crashes, we need to analyze the crash log to help identify the root cause of it. The crash could be a “Low Memory Crash” or a “Normal Crash with Exceptions“. When it comes with “Exception”, a better understanding on “different types of exceptions” can truly help us target the issue quickly.

In this post, we will look into the different types of “exceptions” the iOS app can have, like EXC_CRASH, EXC_BAD_ACCESS, EXC_RESOURCE, 00000020, etc.

Table of Contents [show]

“Exception” in Crash Log

The term “Exception” in the context of “crash log” is more related to “Mach Exception” (with a prefix “EXC_“) and “UNIX signal” (like SIGSEGV, SIGBUS, etc.). In some cases, the “kernel” also does mapping to translate underlying “Mach Exception” to a “UNIX signal”. And this is the reason why you can see “EXC_CRASH (SIGABRT)” and “EXC_BAD_ACCESS (SIGSEGV)” shown in the crash log as “Exception Type”.

For some of the exceptions, it is also attaching an associated processor-specific Exception Code / Exception Subtype that contains further information about the problem. For example, exception type “EXC_BAD_ACCESS” could have a line like “KERN_INVALID_ADDRESS at 0x80000010” shown as “exception code”; “EXC_RESOURCE” could have line “WAKEUPS” shown as “exception subtype”.

UNIX Signals

Here is a list of UNIX signals that are usually shown in front of iOS developers.

UNIX Signals Annotations
SIGSEGV Access to an invalid memory address. The address exist, but your program does not have access to it.
SIGABRT Program crash. It is initiated by C function abort(). It normally means that the system detects something wrong, like an assert() or NSAssert() fails.
SIGBUS Access to an invalid memory address. The address does not exist, or the alignment is invalid.
SIGTRAP Debugger related.
SIGILL Attempts to execute an illegal, malformed, unknown, or privileged instruction.

More UNIX signals can be found from here

Mach Exceptions

Mach Exception Decription Annotations
EXC_BAD_ACCESS Bad Memory Access Access to “bad” memory address. The “bad” can be either “the address does not exist” or “the app does not have privilege to access to”. So it usually ties to SIGBUS and SIGSEGV.
EXC_CRASH Abnormal Exit Usually tie to SIGABRT, meaning the app exits abnormally by detecting some uncaught exceptions through the code.
EXC_BREAKPOINT Trace / breakpoint Trap Usually tie to SIGTRAP. Can be triggered either by your own code or NSExceptions being thrown.
EXC_GUARD Violated Guarded Resource Protection Be triggered by violating a guarded resource protection, like “certain file descriptor”.
EXC_BAD_INSTRUCTION Illegal Instruction Usually related to certain illegal or undefined instruction or operand.
EXC_RESOURCE Resource Limit App crashes by hitting resource consumption limit.
00000020 Hexadecimal Exception Type Not “OS Kernel” exception.

For the entire list of Mach Exceptions, check the source code file (sys/osfmk/mach/exception_types.h) from here.

Exceptions

EXC_BAD_ACCESS (Bad Memory Access)

“EXC_BAD_ACCESS” is one of the most popular exceptions when app crashes. Unfortunately, it is not easy to debug.
Normally it has two likely possibilities:

  • Accessing something not initialized yet (SIGBUS).
  • Accessing something already released by ARC so that the address becomes inaccessible (SIGSEGV). In this case, you should usually see objc_release is near the top of the “Backstrace” in crash log.

Here are some examples:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x6d783f44
...
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000011

“EXC_BAD_ACCESS” also has associated “exception code” to help provide additional info. For example, KERN_PROTECTION_FAILUREindicates the memory is valid, but it does not permit the required forms of access, and KERN_INVALID_ADDRESS means address is not currently valid.

Check the source code file (sys/osfmk/mach/kern_return.h) from here to get a full list of possible values.

To help debug “EXC_BAD_ACCESS”, you can check “Enable Zombie Objects” in Xcode and try it again.

Xcode - Enable Zombie Objects

Image source: “Google Images”.

EXC_CRASH (Abnormal Exit)

Comparing to “EXC_BAD_ACCESS”, “EXC_CRASH” is usually a good one to encounter. Usually, it happens when an object receives an unimplemented message, as the line “unrecognized selector sent to instance 0x6a33840” shown in Xcode debugger.

Normally, this exception is indented to be worked with debugger as the debugger can break (interrupt) the process. If no debugger attached, a crash log will be generated instead.

Here is an example info shown in crash log.

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
...
## Usually you will see a similar line in the "backtrace" part
2 CoreFoundation 0x36c02e02 -[NSObject(NSObject) doesNotRecognizeSelector:] + 166

It may also have some special cases that are not related to “unrecognized selector”. If that happens, please be careful – things can happen everywhere.

Another common case of “EXC_CRASH” is about “App Extensions”. The App Extension can be terminated by OS if it “took too much time to initialize”. In this case, it shows “LAUNCH_HANG” in Exception Subtype as well as a very decent Exception Message.

Exception Type: EXC_CRASH (SIGABRT)
Exception Subtype: LAUNCH_HANG
Exception Message: The extension took too much time to initialize

EXC_BREAKPOINT (Trace Trap)

Much like “EXC_CRASH”, it is more like to work with debugger and caught during your testing phase.

When using Swift, this exception will be thrown at runtime if:

  • a non-optional type with a nil value
  • a failed forced type conversion

An example info is like this:

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000

You can manually call __builtin_trap() in your code to trigger this exception.

EXC_GUARD (Violated Guarded Resource Protection)

Unlike all other “EXC_” exceptions, this one is not a “native” Mach Exceptions. In fact, it is added into XNU – a derived OS kernel developed by Apple.

“XNU” stand for “X is Not Unix”.

The definition of “EXC_GUARD” can be found from here – osfmk/mach/exception_types.h.

A good example of this exception is that the app closes the “file descriptor” of SQLite file while Core Data is accessing it.

Prior to iOS 7, this exception attaches a part of “Exception Codes” to help understand the situation. The “Exception Codes” contains “two” bitfields – code (e.g. 0x400000010000005e) and subcode (e.g. 0x00007f8254a019c0).

  • code part breaks down into “three” sections:
  • [63:61] Guard Type – At the moment, it only has one type – guarded file descriptor (GUARD_TYPE_FD). Its value is 0x2. So if you can see 0x4 as the prefix of code, the crash is about “file descriptor”.
  • [60:32] Flavor – Different conditions when violating “guarded file descriptor”:
  • If “first” ([32]: "1 << 0") bit is set (kGUARD_EXC_CLOSE), it attempted to invoke close() on a “guarded file descriptor”.
  • If “second” ([33]: "1 << 1") bit is set(kGUARD_EXC_DUP), it attempted to invoked dup(2), dup2(2), fcntl(2) with F_DUPFD or F_DUPFD_CLOEXEC on a “guarded file descriptor”. It also cover the attempt to open a “guarded file descriptor” by /dev/fd/.
  • If “third” ([34]: "1 << 2") bit is set (kGUARD_EXC_NOCLOEXEC), it attempted to close the “close-on-exec” flag on a “guarded file descriptor”.
  • If “fourth” ([35]: "1 << 3") bit is set (kGUARD_EXC_SOCKET_IPC), it attempted to send a “guarded file descriptor” via a socket.
  • If “fifth” ([36]: "1 << 4") bit is set (GUARD_FILEPORT), it attempted to create a fileport from a “guarded file descriptor” via a socket.
  • If “sixth” ([37]: "1 << 5") bit is set (kGUARD_EXC_MISMATCH), the “guard” of a “guarded file descriptor” was mismatch.
  • If “seventh” ([38]: "1 << 6") bit is set (kGUARD_EXC_WRITE), it attempted to write on a “guarded file descriptor” via a socket. – [31:0] – File Descriptor – The guarded file descriptor that the app attempted to operate. – subcode part contains the “guard value”. > Detailed definition can be found from here – /bsd/sys/guarded.h.

Starting from iOS 7, “Exception Codes” is replaced by “Exception Subtype” and “Exception Message” which provides much more clear explanation.

# iOS 6
Exception Type: EXC_GUARD
Exception Codes: 0x400000010000005e, 0x00007f8254a019c0
# The type is "GUARD_TYPE_FD" (0x4), with "kGUARD_EXC_CLOSE". The FD is "94".
# -------
# iOS 7 and above
Exception Type: EXC_GUARD
Exception Subtype: GUARD_TYPE_FD
Exception Message: CLOSE on file descriptor 81 (guarded with 0x0000000017e6eed0)

EXC_BAD_INSTRUCTION (Illegal Instruction)

“EXC_BAD_INSTRUCTION”, usually ties to “SIGILL“, is a very easy-understood exception – you are using the “wrong” instruction or operand. However, it is sometimes very hard to debug.

Here are some common ones.

This one is easy to identify because of the debug info Xcode provides – it is caused by an unsafe unwrapping.

## Usually show "EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" in Xcode.
“fatal error: unexpectedly found nil while unwrapping an Optional value”

However, the ones like this and this are not easy – the first one is about GCD using and the other one is about a Apple bug!

Here is the format when showing in crash log:

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x000000000000b6d2

EXC_RESOURCE

“EXC_RESOURCE” means the process “hits a resource consumption limit”. Usually, it will be triggered when your app constantly runs beyond the limit over certain period.

This exception includes “Exception Subtype” to help understand the actual cases:

  • CPU – The limit is 50% and the period is 180 sec.
  • WAKEUPS – Indicate that a thread was waking up too many times per second. The limit is 150/sec and the period is 300 sec.
  • MEMORY – The limit is “not documented”.

Like “EXC_GUARD”, it used to use “bitfields” to convey info, and now it also use “Exception Subtype” and “Exception Message”.

Exception Type: EXC_RESOURCE
Exception Subtype: CPU
Exception Message: (Limit 50%) Observed 85% over 180 secs
---
Exception Type: EXC_RESOURCE
Exception Subtype: WAKEUPS
Exception Message: (Limit 150/sec) Observed 206/sec over 300 secs
---
Exception Type: EXC_RESOURCE
Exception Subtype: MEMORY
Exception Message: Crossed High Water Mark

00000020

Unlike “EXC_” exceptions, the “Exception Type” actually cannot tell you any info. Instead, you should check “Exception Codes” for more details.

  • 0x8badf00d(read as ate bad food) – Indicate the app was terminated by OS by because a watchdog timeout occurred. It usually means the app too long to launch, terminate, or respond to system events. A very typical case of it is to “do synchronous networking on the main thread”.
  • 0xbaaaaaad(read as “plooookhy”) – Indicate the log is a stackshot of the entire system, not a crash report.
  • 0xc00010ff(read as cool off) – Indicate the app was forecely closed by OS in response to a thermal event.
  • 0xbad22222 – Indicate a VoIP application was terminated by OS since it resumed too frequently.
  • 0xdead10cc(read as dead lock) – Indicate the app held on to a system resource while running in the background.
  • 0xdeadfa11(read as deadfall) – Indicate the app was forcedly closed by user. Force quits occur when the user first holds down the Power button until “slide to power off” appears, then holds down the Home button.

These “hexadecimal” codes are actually hexspeak words – created by our developers as memorable magic numbers.


转:http://www.5neo.be/understanding-ios-exception-types/

【信息科学与工程学】【安全领域】第八十三篇 云安全解决方案02 企业中“搞人”与“搞事情”常见问题的分析框架。我将选取4个典型场景,每个场景都从实际管理现象出发,逐步推导出数学模型、参数设定及关联知识。 阅读详情

相关推荐

手把手教你用FPGA实现SerDes高速接口设计(附避坑指南)

本文是一份详尽的FPGA SerDes高速接口设计实战指南。文章深入剖析了SerDes硬核(如GTX/GTH)的时钟管理、发送端均衡、接收端CDR与均衡等核心模块,并提供了Verilog代码示例。重点分享了信号完整性分析、眼图调试与误码率测试等实战经验,附有自定义高速视频流接口的完整实现案例与避坑指南,帮助工程师从“会用”到“懂”且能独立驾驭高速接口设计。

ik678901234的博客 1144

iOS Crash 分析

EXC_BAD_ACCESS 是异常类型,这钟类型表示访问了已经被release或者不存在的对象,导致出错,有时候会运行正常,这种情况说明被release的内存,被重用了,这就是常说的僵尸信号, KERN_PROTECTION_FAILURE意思如下:  操作系统不允许用户访问(读/写)的内存地址类型,地址0x00000009就是这样的类型,经常导致的原因就是使用了从来都没有被初始化的

缘故的博客 708

逆变器方案(工频全套)工频正弦波逆变器开发板全套设计资

逆变器方案(工频全套)工频正弦波逆变器开发板,24V-72V通用12只TO-247封装MOS管,额定输出功率6500W以下;配有触摸屏操作界面,运行数据一目了然,带市电互补UPS功能,可选择电池优先或市电有限工作,我们的开发板均从实战角度出发,让您的学习更便捷,包含全套设计资料,PCB.原理图.源代码,程序均有中文注释,MCU选用美国微芯公的PIC-8位单片机,民用数字电源首选单片机,抗干扰能力强,运行稳定。...

m0_73494033的博客 890

iOS【EXC_BAD_ACCESS 】crash报告分析

做iOS的开发者,经常都会遇到这个问题,我在这里做一下简单的分析 下面是crash log,摘自:【EXC_BAD_ACCESS 】crash报告的问题 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000009 Crashed Thread: 0 ...

bengan的专栏 1465

primetime如何做voltage scaling

存在这样的情况,标准单元库只有ssgnp0p72vm40c和ssgnp0p9vm40c的libs,但是我们希望它工作在ssgnp0p76vm40c,这样的话就需要用ssgnp0p72vm40c和ssgnp0p9vm40c的libs来scaling出ssgnp0p76vm40c的lib。

qq_34326957的博客 1683

动态表单设计

自定一表单数据结构。内容展示如有必要行转列。前端根据题目类型自定义组件后端跟俊题目类型用策略模式校验各种类型这样有统计功能的简单动态问卷就可以了展示时可能某些场景需要行转列。大概估摸使用的话有可能kmic_form_data_detail表的记录数比较大,后期再考虑数据或者表迁移或拆分。

zquwei的博客 3451

iOS应用崩溃日志揭秘

转自 http://www.raywenderlich.com/zh-hans/30818/ios应用崩溃日志揭秘 本文作者是 Soheil Moayedi Azarpour, 他是一名独立iOS开发者。 作为一名应用开发者,你是否有过如下经历? 为确保你的应用正确无误,在将其提交到应用商店之前,你必定进行了大量的测试工作。它在你的设备上也运行得很好,但是,上了应用商店后

cy-app 6万+

SPH vs Lagrange网格混合建模实战:用LS-DYNA模拟弹丸穿孔效应

本文深入探讨了在LS-DYNA中运用SPH与Lagrange网格混合建模技术,高效模拟超高速碰撞下弹丸穿孔效应的实战方法。通过分析模型分区策略、耦合界面处理及关键参数设置,解决了传统方法在模拟大变形、材料断裂时的网格畸变或计算成本高昂问题,为相关工程仿真提供了兼顾精度与效率的解决方案。

weixin_29211309的博客 108

iOS Crash日志

Understanding Crash Reports on iPhone OS https://developer.apple.com/videos/wwdc/2010/?id=317 http://www.cnblogs.com/smileEvday/p/Crash1.html http://www.cocoachina.com/industry/20130725/6677.html ...

weixin_30311605的博客 437

MobaXterm破解14个会话限制的保姆级教程(附Python环境配置指南)

本文提供了MobaXterm破解14个会话限制的详细教程,并深入讲解了如何配置稳定的Python环境以支持相关脚本运行。通过理解软件授权机制、安全实践步骤以及许可文件的应用,帮助用户解除会话数量限制,实现高效的远程服务器管理与自动化运维。

weixin_29211309的博客 1628

HTML粉色爱心(完整代码)

HTML语言实现粉色爱心的完整代码。

AIGC 1104

闪退后系统的崩溃记录

报错

guling0420的博客 4267

Python从0到100(二):Python语言介绍及第一个Pyhon程序

Python从0到100(二):Python语言介绍及第一个Pyhon程序。与C和Java比,Python的学习成本和难度曲线不是低一点,更适合新手入门,自底向上的技术攀爬路线。

拥有百余位万粉技术博主、200余位可合作代发博主,私域技术社群规模达千人,商务合作私信 5437

2024 RAG范式升级:从静态流水线到认知智能体

RAG(检索增强生成)已从早期的文档检索+大模型生成,演进为具备查询理解、动态路由与自纠错能力的认知协同系统。其核心原理在于打破传统pipeline的语义断层与意图断层,通过结构化意图解析、多跳语义检索和用户反馈驱动的闭环进化,显著提升事实准确率与业务响应效率。技术价值体现在降低幻觉率、压缩首字延迟、支持复杂推理,并天然适配金融合规、医疗问答、工业维修等强专业、高时效、多语言场景。本文聚焦Query Understanding、Dynamic Routing与Self-Correction三大新范式,提供可

chuange6363的博客 397

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

iPhone开发技巧之调试篇— 程序Crash后的调试技巧

6十一/110 原文链接 : http://www.yifeiyang.net/iphone-development-skills-of-debugging-articles-3-crash-after-debugging-skills-program/ 转载请保留上面文字。 模拟器上显示堆栈信息 在iPhone上输出日志 iPhone应用程序的CrashReporter

Annie的专栏 2797

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

调试iOS 已经发布代码 Crash 文件分析出出错对应代码

1.需要发布代码的 对应 app和.dSYM 位置Xcode4.5.2 通常在/User/<用户名>/Developer/Xcode/Archives/目录下 找到对应的应用 显示包内容,将其中的应用和.dSYM(例如我的应用名称为:guola)guola.app 和对应guola.dSYM 复制到桌面上。2.将工具从/Applications/Xcode.app/Conte...

weixin_30505485的博客 286

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

iOS 奔溃EXC_BAD_ACCESS(KERN_INVALID_ADDRESS)分析

EXC_BAD_ACCESS (KERN_INVALID_ADDRESS)是一种常见的iOS应用程序崩溃错误

Hello World 9528

UncaughtExceptionHandler

61.常见的Exception Type 1 EXC_BAD_ACCESS 在开发过程中,总是会遇到各种Exception,在此总结一些常见的Exception。 NSInvalidArgumentException 错误类型 NSInvalidArgumentException log输出 unrecognized selector sent to instance xxxx 错误释义 给实体对象发送了不认识的消息,即对象调用方法出错 错误基本原因 Objective-C的方法调用其实是基于消息传递机制,

More reading and learning to become excellent 1966

idea通过MacOS文件夹内的idea控制台可运行,应用程序无法运行,闪退(急急急)

第一张图片是运行应用程序闪退的问题报告 第二张是运行macOS内的idea控制台的log 麻烦大家看下怎么解决 哭辽

sun616818的博客 1560

iOS App 后台任务的坑

大多数 iOS App 在进入后台之后都会将一些关键任务封装到 Background Task 里,否则程序在若干秒之后就会被系统 Suspend。启动 Background Task 之后,可以获得 3 分钟继续执行代码的时间。 最近在调查 Messenger 的 Background Crash 问题,最后都追踪到和 Background Task 相关,和大家分享下一些要点。 Crash...

马甲包开发审核交流群:869685378 841

iOS crash文件解析及常见的Exception类型

crash文件 当运行的APP发生crash的时候,如果代码里面增加对应的handler或者有第三方的crash SDK,他们会采集相关的运行堆栈,发送到对应的服务器上,然后通过开发者上传的dsym文件进行解析,得到符号化的堆栈信息,我们可以通过分析这个知道crash的原因。另外,当发生crash的时候,相应的设备上也会生成一个crash文件。我们可以通过Xcode导出crash文件。 ...

lionzl的专栏 3701

[译]理解 iOS 异常类型

原文链接:Understanding iOS Exception Types(PS.由于未知原因已失效,经检查,文章中引用的链接都还有效 :) 翻译:CoderWangx 当你的iOS应用崩溃的时候,我们需要去分析异常日志以定位根本原因。崩溃可能是 “低内存崩溃Low Memory Crash” 或者 “普通异常崩溃”。当碰到“异常”时,更好的理解“不同类型的异常”能够真正帮助我们快速定位问题所在。 在这篇文章中,我们将研究 iOS 应用可能碰到的不同类型的“异常”,例如EXC_CRASH、E...

u012338816的专栏 1692

iOS SIGKILL 信号量崩溃抓取以及优化实践

很多时候,当我们在崩溃日志中看到 SIGKILL 关键信息的时候,这就表示操作系统从上层杀死了我们的进程,也就是我们常说的 kill -9 命令。

lihui49的博客 1321

iOS_Crash 二:报告的组成结构

二进制图像,崩溃报告的二进制图片部分列出了终止时进程中加载的所有代码(如:应用程序可执行文件和系统框架)。之后的每一行代表回溯中的一个堆栈帧,堆栈帧的每一列都包含崩溃时执行的代码信息。第一列:堆栈帧号,堆栈帧按调用顺序排列,其中0帧是执行停止时正在执行的函数,1帧则是调用0帧的函数,以此类推。操作系统有时会包含额外的诊断信息,这些信息使用多种格式,具体取决于崩溃的原因,并不是每个崩溃报告都包含。第三列:正在执行的机器指令的地址。第四列:在完全符号化的崩溃报告中,正在执行的函数名称。

mikimo的博客 967
上一篇: iOS Crash 类型
下一篇: 正则表达式在iOS中的运用
直隶码农
博客等级 码龄19年 95粉丝 103原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值