ndk-stack不能得到满栈 [英] ndk-stack can not get full stack

查看:218
本文介绍了ndk-stack不能得到满栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一段代码,为了测试ndk-stack
这里是代码片段

I wrote a piece of code, in order to test the ndk-stack Here is the code fragment

libtest.so

libtest.so

    std::vector<int> testVec;

    testVec.at(500);

但我得到的是不完整的堆栈

But I get was incomplete stack

********** Crash dump: **********
Build fingerprint: 'MI/casablanca_icntv/casablanca:4.2.2/CADEV/1253:user/release-keys'
pid: 24989, tid: 24989  >>> com.ktcp.video <<<
signal 11 (SIGSEGV), fault addr deadbaad
Stack frame #00  pc 0001a852  /system/lib/libc.so: Routine ????:0
Stack frame #01  pc 00018190  /system/lib/libc.so (abort): Routine ????:0
Stack frame #00  pc 0001a852  /system/lib/libc.so: Routine ????:0
Stack frame #01  pc 00018190  /system/lib/libc.so (abort): Routine ????:0
Stack frame #00  pc 0001a852  /system/lib/libc.so: Routine ????:0
Stack frame #01  pc 00018190  /system/lib/libc.so (abort): Routine ????:0
Stack frame #00  pc 0001a852  /system/lib/libc.so: Routine ????:0
Stack frame #01  pc 00018190  /system/lib/libc.so (abort): Routine ????:0
^C^C

在堆叠中没有看到我的代码,堆栈不完整

In the stack did not see my code, incomplete stack

如何修复

推荐答案

0xdeadbaad 来表示故意中止。你可以看到对你的堆栈的片段调用 abort()。我猜你会触发断言失败(会出现在logcat中)。

0xdeadbaad was used by Bionic libc to indicate a deliberate abort. You can see a call to abort() on the fragment of stack you do get. I'm guessing you're triggering an assertion failure (which would show up in logcat).

在某些版本的Android上,在某些情况下,从 abort()的良好跟踪。部分问题是,函数被标记为 noreturn 属性,所以编译器不会吐出投诉,当你这样做:

On some versions of Android, in some circumstances, you don't get a good trace from abort(). Part of the problem is that the function was tagged with the noreturn attribute so the compiler wouldn't spit out complaints when you did something like this:

int foo(int x) {
    if (x == 0) {
        return 12345;
    } else {
        abort();
    }
}

如果 abort / code>返回,此方法将返回未定义的值。在ARM上,返回地址存在于LR寄存器中,并且如果必要的话保存在堆栈上...但是如果函数不返回,则不需要保存返回地址,因此允许编译器抛出它远。这是伟大的,直到你想有堆栈跟踪的地址。如果LR被重用,并且旧的值没有溢出到堆栈,它只是消失了。

If abort() returned, this method would return an undefined value. On ARM, the return address lives in the LR register, and is preserved on the stack if necessary... but if the function doesn't return, then there's no need to save the return address, so the compiler is allowed to throw it away. This works out great until you want to have that address for the stack trace. If LR gets re-used, and the old value wasn't spilled to the stack, it's simply gone.

我认为可能有一个版本,其中编译器问题是固定的,但是一些汇编器元数据是错误的,导致类似的麻烦。

I think there might have been a release where the compiler issue was fixed, but some assembler meta-data was wrong, leading to similar trouble.

最近的Android版本不应该出现这种行为。最近的版本还替换了对更传统的SIGABRT访问 0xdeadbaad ,所以你不再看到这个特殊的崩溃签名。

Recent versions of Android should not exhibit this behavior. Recent versions also replaced access to 0xdeadbaad with the more traditional SIGABRT, so you no longer see this particular crash signature.

(FWIW,您可以看到 noreturn 在4.2.2(见评论)。它在系统的早期版本中工作。)

(FWIW, you can see an attempted workaround for noreturn in 4.2.2 (see comments). It worked in earlier versions of the system.)

这篇关于ndk-stack不能得到满栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆