You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The '\examples\peripherals\spi_slave_hd\segment_mode\seg_slave' contains a bug, which causes the example failure, if the C compiler optimization level is -Os or -O2.
Expected Behavior
Must work normally.
Actual Behavior
Throws an exception:
'E (220) SEG_SLAVE: No enough memory!'
Steps to reproduce
Go to '\examples\peripherals\spi_slave_hd\segment_mode\seg_slave' dir.
Run idf.py menuconfig.
Go to 'Compiler options', 'Optimisation options'.
Set '-Os' or '-O2' level.
Compile and flash the example.
Get the 'E (220) SEG_SLAVE: Not enough memory!' error.
Quite basic.
The variables are created on stack which is different when passed to a task. Both void receiver(void *arg) and void sender(void *arg) receive garbage in 'arg'.
What works in -O0 will fail in -Os. The variables should be set to 'static' so that they put in .bss.
This type of bug might be present in other code snippets as well, so I suggest to check them.
github-actionsbot
changed the title
Bug in example 'spi_slave_hd\segment_mode\seg_slave' when -Os or -O2 is set for CC
Bug in example 'spi_slave_hd\segment_mode\seg_slave' when -Os or -O2 is set for CC (IDFGH-5420)
Jun 17, 2021
Environment
Problem Description
The '\examples\peripherals\spi_slave_hd\segment_mode\seg_slave' contains a bug, which causes the example failure, if the C compiler optimization level is -Os or -O2.
Expected Behavior
Must work normally.
Actual Behavior
Throws an exception:
'E (220) SEG_SLAVE: No enough memory!'
Steps to reproduce
Code to reproduce this issue
The bug reason
Quite basic.
The variables are created on stack which is different when passed to a task. Both void receiver(void *arg) and void sender(void *arg) receive garbage in 'arg'.
What works in -O0 will fail in -Os. The variables should be set to 'static' so that they put in .bss.
This type of bug might be present in other code snippets as well, so I suggest to check them.
Code fixes
The text was updated successfully, but these errors were encountered: