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

是否所有的native异常都能捕获? #20

Closed
foobra opened this issue Sep 24, 2019 · 4 comments
Closed

是否所有的native异常都能捕获? #20

foobra opened this issue Sep 24, 2019 · 4 comments
Labels
invalid This doesn't seem right

Comments

@foobra
Copy link

foobra commented Sep 24, 2019

我发现有个空指针异常没有捕获 其他情况可以捕获.
ClassFoo *foo = nullptr;
foo->testFunc();

第二行crash的时候 无法捕获

@caikelun
Copy link
Collaborator

这种明显有问题的代码release编译时(-Os -Oz)一般都会被优化掉,比如编译成 exit 了。请反汇编确认。

此类测试代码建议用 -O0 编译。

@waruqi
Copy link

waruqi commented Sep 24, 2019

加个volatile 就好了。

volatile ClassFoo *foo = nullptr;
foo->testFunc();

或者直接:*((volatile int*)0) = 0;

@foobra
Copy link
Author

foobra commented Sep 25, 2019

这种明显有问题的代码release编译时(-Os -Oz)一般都会被优化掉,比如编译成 exit 了。请反汇编确认。

此类测试代码建议用 -O0 编译。

我只是举个例子, 这个ClassFoo很可能是外部传入的. 然后崩溃了. ndk自己都抓不到这种堆栈, xcrash是否能抓到?

@caikelun
Copy link
Collaborator

xCrash 的 log 文件能生成吗?还是说 log 文件中的 backtrace 为空?
另外可以确认下,是否在 xCrash 初始化之后,进程中又有其他地方注册了崩溃信号的 handler?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants