for some time now, I'm searching a bug which is really hard to find. Anyway, I reduced everything to a very small example code which crashes after several seconds.
The Scenario is described as:
- main1() and main2() are auto created tasks, started by MQX init
- both are just loops which are creating dynamic tasks dynamic1() and dynamic2()
- I'm using Kinetis K64-120 MHz, 256KB SRAM
- MQX Version is 126.96.36.199, so this should be fixed already: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal
Sometimes, _lwmem_test() reports Error 7 before everything hangs, which is MQX_CORRUPT_STORAGE_POOL_FREE_LIST, but more likely my system hangs before this is reported...
main.c and main.h is attached.
If I enabled MQX_USE_MEM instead of MQX_USE_LWMEM, the problem is gone, which makes me think there is an lwmem problem. On the other hand, the problem is also gone when enabling _time_delay(1) at the end of main2() and staying with lwmem.
This seems very related to my Problem: stuck in _lwmem_get_next_block_internal()
When the error condition occurs, _task_destroy_internal calls _lwmem_get_next_block_internal(), and than_lwmem_get_next_block_internal() crashes when trying to skip free blocks.