Skip to main content
dmarks-ls
Associate III
August 19, 2026
Question

STM32H563 ThreadX crash during nested interrupt - what's the likely culprit?

  • August 19, 2026
  • 3 replies
  • 58 views

So I left my program running overnight, and when I check it this morning, the debug output had stopped.  Thankfully, the IDE was still running, and it actually caught the hard fault, and even better, the call stack was intact.  Here’s what I saw:

Call stack showing nested interrupts while running ThreadX

So the IP thread was running, it was waiting on an event flag, another small handler popped, then the Ethernet IRQ popped, and before it could finish execution, the CAN handler popped.  The CAN handler checks a queue (with TX_NO_WAIT) for items to transmit, but just before it started executing _tx_queue_receive(), a HardFault occurred.

This is the view from inside _txe_queue_receive():

_txe_queue_receive() context

And this is the view from inside _tx_queue_receive():

_tx_queue_receive() context

Now, I’m not sure if perhaps the program counter hadn’t gotten far enough to populate/adjust the stack so that the local variables look correct, but I can see that _txe_queue_receive() definitely had valid values for queue_ptr, destination_ptr, and wait_option prior to calling _tx_queue_receive().

For reference, here are the CPU registers:

CPU registers

In my linker file, I have _Min_Stack_Size = 0x400 (1 kByte).  I’m wondering two things:

One, from an RTOS safety perspective, is it fine that the CAN ISR popped in the middle of the Ethernet ISR?  Are there no kernel safety issues surrounding that?  Presumably if there were an issue, the solution would be to give ThreadX-interacting ISRs all the same NVIC priority, so that no one ISR could preempt another.

Two, is it more likely that the 1 KB hardware stack was simply exceeded with that large call stack, and I just need to increase the size of the hardware stack to, say, 4 KB to compensate?  Appreciate any perspective, thanks.

Dana M.

3 replies

Pavel A.
August 19, 2026

Whenever you say “HardFault”, you immediately open the fault analyzer tool in CubeIDE - it exists there exactly for this!

 

dmarks-ls
dmarks-lsAuthor
Associate III
August 19, 2026

… well, how ‘bout that.  I’ll remember that for next time.  Not used to IDEs having analytical features, especially ones that work.

boiled-potato
Associate
August 19, 2026

well first you should check what type of fault it is , 

most likely its stack overflow due to poor isr structure. 

 

isr job is not to do things on its own, deferred interrupt processing is the industry standard. isr should only act as trigger and exit asap.