Git Product home page Git Product logo

Comments (11)

enh avatar enh commented on August 22, 2024 9

we're looking at adding <execinfo.h> (http://man7.org/linux/man-pages/man3/backtrace.3.html) in a future release.

from ndk.

dipankar08 avatar dipankar08 commented on August 22, 2024

Here is the callstack. we are getting this for ARM build. As you can see the IP of the below stack is completely wrong.

03-08 17:27:17.796 19915 20022 E FOO       : #######################  EXCEPTION CALLSTACK  ######################### 
03-08 17:27:17.799 19915 20022 E STACKTRACE: Frame:[#0]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.799 19915 20022 E STACKTRACE: Frame:[#1]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.799 19915 20022 E STACKTRACE: Frame:[#2]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#3]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#4]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#5]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#6]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#7]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#8]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#9]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#10]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#11]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#12]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#13]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#14]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#15]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.800 19915 20022 E STACKTRACE: Frame:[#16]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.801 19915 20022 E STACKTRACE: Frame:[#17]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.802 19915 20022 E STACKTRACE: Frame:[#18]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#19]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#20]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#21]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#22]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#23]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#24]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#25]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#26]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#27]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#28]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#29]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]
03-08 17:27:17.803 19915 20022 E STACKTRACE: Frame:[#30]            IP:[0x70902cd4]       Function:[SetLastExceptionInfoForThread()]

BTW, there are an easier way to get the callstack in linux by using backtrace () as part of execinfo.h, which is not supported for Android. Do you have any plan to get this header/so inplace in future version of android ?

I am using clang compiler with androidndk.10.4.1 tool chain.

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

You don't need to backtrace yourself. debuggerd is a built in part of android that will print a backtrace of your app when it crashes.

As for fixing the underlying bug, we need more information. What STL are you using?

androidndk.10.4.1 tool chain

There's no such thing. Is that an Android Studio version? Are you using NDK r11b? If you're not using r11b, that's the first thing to check.

from ndk.

dipankar08 avatar dipankar08 commented on August 22, 2024

Hello,

We are using r10d only as r10e had toolchain problems.
We are currently using clang3.5. and gcc4.9 (for support toolchain)
We are using stl library located at sources\cxx-stl\gnu-libstdc++ in the NDK.

Thanks
Dipankar

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

Reopen if this is still present in r11b. Clang has been completely redone (we threw away the old crappy hacked about source that was in the NDK and reset to upstream), so there's a significant chance the problem will go away just by upgrading.

from ndk.

minggo avatar minggo commented on August 22, 2024

debuggerd is a built in part of android that will print a backtrace of your app when it crashes.

@DanAlbert does it work in release mode too? Can it work only using clang, or can also work with gcc?
Thanks.

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

As long as your app can be unwound (debuggerd will try a lot of different ways to do this), it will be unwound. Should work with essentially any binary.

from ndk.

minggo avatar minggo commented on August 22, 2024

Thanks.
What does your app can be unwound mean?

from ndk.

DanAlbert avatar DanAlbert commented on August 22, 2024

As long as you haven't gone out of your way to obfuscate it then it should be fine.

from ndk.

bsergean avatar bsergean commented on August 22, 2024

Hi there,

Computing a backtrace can be very helpful in other context, rather than just for handling crashes. For example in a large code base you can record where an API is used, and put that in an associative array (key = backtrace, value = hit-count). It can be used for ad'hoc memory leak detector etc...

Obviously I am not aware of the complexity of support this, but it would make the Android platform more developer friendly and comparable to other platform (this is available in Linux and macOS) to do so.

from ndk.

alexeikh avatar alexeikh commented on August 22, 2024

Before <execinfo.h> is added, maybe my small app for testing 3 backtracing methods on Android will be helpful for someone: https://github.com/alexeikh/android-ndk-backtrace-test

from ndk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.