Stack issues with fast interrupts
Posted: Tue Dec 01, 2020 4:49 pm
Hi,
I'm bumping into some weird issues where I see the idle thread's stack overflowing but I can't quite catch it in the act due to watchpoints not working on my setup. I'm on an STM32H7, but I think this is applicable to all ARM v7m.
After testing out everything, it seems that if I switch a fast interrupt to be a regular one (plus some changes to handle it not keeping up) it stops happening, but the two configurations are not exactly equivalent.
Is that possible?
I'm using a debug build with all the various ChibiOS checks and tracing enabled, FILL_THREADS, and no custom hooks. I increased the idle stack size from the default of 16 to 256, and when the fast interrupt is enabled I see the untouched stack space going down to 192 bytes after letting it run for a while, whereas using a regular interrupt I get 364 bytes.
Reading the code, I think the only possibility is that in _port_switch_from_isr, the fast interrupt is triggered before chSchDoReschedule can complete the switch and unlock. So its stack plus the fast interrupt stored registers make it go over the limit.
Does that seem possible? The part that still doesn't make sense to me is that if that was the case I think it would take at most an additional sizeof(port_intctx), which for my build settings should be 100 bytes, but enabling the fast interrupt results in 172 additional bytes of stack space used, and I can't figure out where those other 72 bytes come from.
GB
I'm bumping into some weird issues where I see the idle thread's stack overflowing but I can't quite catch it in the act due to watchpoints not working on my setup. I'm on an STM32H7, but I think this is applicable to all ARM v7m.
After testing out everything, it seems that if I switch a fast interrupt to be a regular one (plus some changes to handle it not keeping up) it stops happening, but the two configurations are not exactly equivalent.
Is that possible?
I'm using a debug build with all the various ChibiOS checks and tracing enabled, FILL_THREADS, and no custom hooks. I increased the idle stack size from the default of 16 to 256, and when the fast interrupt is enabled I see the untouched stack space going down to 192 bytes after letting it run for a while, whereas using a regular interrupt I get 364 bytes.
Reading the code, I think the only possibility is that in _port_switch_from_isr, the fast interrupt is triggered before chSchDoReschedule can complete the switch and unlock. So its stack plus the fast interrupt stored registers make it go over the limit.
Does that seem possible? The part that still doesn't make sense to me is that if that was the case I think it would take at most an additional sizeof(port_intctx), which for my build settings should be 100 bytes, but enabling the fast interrupt results in 172 additional bytes of stack space used, and I can't figure out where those other 72 bytes come from.
GB