TG9541/stm8ef

Interrupt and background data stacks coincide

Closed this issue · 3 comments

The file inc/defconf.inc has two defines for the background data stack size:
BG_STACKSIZE = 32 ; Default size in bytes of data stack for background tasks
BSPPSIZE = 0 ; BG task data stack size (bytes) for memory calculation

BG_STACKSIZE is not used effectively in forth.asm. Both the interrupt datastack and the background data stack grow down from $350 ( for a STM8Sx03 ).

Maybe BG_STACKSIZE is redundant and can be removed while BSPPSIZE is set to 32.
Or did I mis something here?

Confirmed - thanks a bunch for reporting this!

  1. Applications that use the BG task and an ISR that uses Forth code may suffer from BG task data stack corruption. This quite obviously bad.
  2. The BG stack has been 8 cells deep since the bug was introduced - this can also lead to foreground task stack corruption!

I'll quickly provide a fix. Also a way to check stack bounds overrun will be provided.

This happened when I factored out the BG code in #377. It was still OK until the 2.2.26 release. The first release that contained this bug was 2.2.27.pre1. 2.2.27 was released 9/Mar/2021 (today that's a month).

That's a Travis-CI / Docker Inc problem:
image