androidc++backtracestack-unwindinglibunwind

unw_init_remote failed with UNW_EBADREG


On android, while collecting traces of a particular native process, I observed that the backtrace of a particular thread of the process was not collected(libunwind is used to collect the backtrace).

First attempt:

12-29 20:47:20.902 13088 13088 W libbacktrace: virtual bool UnwindPtrace::Unwind(size_t, ucontext_t *): unw_init_remote failed -3

12-29 20:47:20.902 13088 13088 E DEBUG   : Unwind failed: tid = 1544: Setup failed

Second attempt:

12-29 20:47:54.683 13135 13135 W libbacktrace: virtual bool UnwindPtrace::Unwind(size_t, ucontext_t *): unw_init_remote failed -3

12-29 20:47:54.683 13135 13135 E DEBUG   : Unwind failed: tid = 1544: Setup failed

From the docs, -3 seems to be UNW_EBADREG. But I am unable to figure out when exactly is this error code is returned?

Any pointers appreciated!


Solution

  • Got some more info regarding why backtrace unwind of that thread was failing - the thread was in "Disk Sleep" or "D" state.