Ndk-stack cannot get full stack
I wrote a code snippet to test ndk-stack Here is a code snippet
libtest.so
std::vector<int> testVec;
testVec.at(500);
But I am getting 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
Didn't see my code on the stack, incomplete stack
How to fix it
source to share
0xdeadbaad
Bionic libc was used to indicate an intentional interrupt. You can call the call abort()
on the chunk of the stack you will receive. I am assuming you are throwing an assertion error (which will show up in the logcat).
In some versions of Android, in some cases, you don't get a good footprint from abort()
. Part of the problem is that the function was tagged with an attribute noreturn
, so the compiler didn't spit out complaints when you did something like this:
int foo(int x) {
if (x == 0) {
return 12345;
} else {
abort();
}
}
If returned abort()
, this method will return undefined. In ARM, the return address lives in the LR register and is stored on the stack if necessary ... but if the function does not return, then there is no need to store the return address, so the compiler is allowed to throw it far away. This works great as long as you don't want to get that address for the stack trace. If LR is reused and the old value was not spilled onto the stack, it just disappeared.
I think there may have been a release where the compiler issue was fixed, but some of the builder metadata was wrong, leading to similar issues.
Recent versions of Android should not exhibit this behavior. Recent versions have also replaced access to the 0xdeadbaad
more traditional SIGABRTs, so you no longer see this particular failure signature.
(FWIW, you can see a workaround attempt for noreturn
in 4.2.2 (see comments) . It worked on earlier versions of the system.)
source to share