Big arrays in functions lead to control crash

Which products are affected?
ETCHC, ETCHM

What happens?
The control crashes, the watchdog is not activated anymore, restart is not possible

When does the problem occur?
If the applied arrays (e. g. ARRAY[0..150] OF STRING) are bigger than the variables of a function and if they are executed in the program, the control will crash.

Possible diagnostics?
CoDeSys goes offline, LEDs at the control show a certain pattern, the watchdog is not activated anymore

Short-term measures/recommendations?
1. Use FB or PRG, since the variables are not on the stack.
2. Transfer only one pointer on the array to the function.

Evaluation:
Generally, a programming like this should not be executed. Functions typically transfer all variables via the stack. In this example for the one variable 150*16 = 2400 Bytes are stored on the stack. Due to the stack with 3000 Bytes the control will consequently crash, since the PLC task consumes approx. 1000 Bytes in idle running mode. The consequences of the crash are not defined. It can happen that the control continues to run for a while, before the exception leads to the complete crash.

URL for linking this AKB article: https://www.lenze.com/en-de/go/akb/200704942/1/
Formulario de contacto