Task WDT triggered in __log2() and weird program behavior

freemind908
Posts: 2
Joined: Wed Jan 26, 2022 5:19 am

Task WDT triggered in __log2() and weird program behavior

Postby freemind908 » Wed Jan 26, 2022 6:02 am

I'm looking into an issue where the system hangs and would trigger task watchdog if enabled. Backtrace reported by WDT looks like the following:
backtrace.png
backtrace.png (136.27 KiB) Viewed 954 times
Seems the hang happens inside a call to __log2(), which is itself a simple function:
  1. __uint32_t
  2. __log2(num)
  3.     __uint32_t num;
  4. {
  5.     __uint32_t i, limit;
  6.  
  7.     limit = 1;
  8.     for (i = 0; limit < num; limit = limit << 1, i++);
  9.     return (i);
  10. }
So I attached gdb to a running (hanging) instance and examined the assembly listing as running on the core:
assembly.png
assembly.png (50.68 KiB) Viewed 954 times
Here is the weird part: the jump address for instruction at <__log2+17> is nowhere inside the valid range (not a start address of an instruction), right? What could be wrong?

Thanks for your help!

freemind908
Posts: 2
Joined: Wed Jan 26, 2022 5:19 am

Re: Task WDT triggered in __log2() and weird program behavior

Postby freemind908 » Wed Jan 26, 2022 9:52 am

Further digging indicates the hang is related to -1 being passed to __log2() and the way this function is implemented (left shift and compare). However, I'm still curious about the jump address not being the start address of any instruction. Is this a feature of Xtensa architecture?

Who is online

Users browsing this forum: No registered users and 40 guests