Issue details
While some detailed build configuration, There are potential stack overflow in thread function named Thread1
|
static THD_WORKING_AREA(waThread1, 128); |
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); |
In this line, Thread1 Allows 128 stack size.
However, after checking the stack using our internally developed tool, it might have 224 Bytes in with some detailed configurations.
Steps to produce
1. In Makefile, Add this line:
In 8 line..
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -fstack-usage
This will help you automatically calculating stack size of each function.
2. Build centSDR normally, using this configurations:
make
Now we can get stack usage file (*.su) for each source file, So we can manually check stack size of each function.
In case of Thread1 :
There are large call stack with this flow:
Thread1(Thread1) => 24 bytes
tlv320aic3204_get_left_agc_gain(tlv320aic3204_get_left_agc_gain) => 32 bytes
i2cMasterTransmitTimeout (i2cMasterTransmitTimeout) => 40 bytes
i2c_lld_master_transmit_timeout(i2c_lld_master_transmit_timeout) => 40 bytes
chThdSuspendTimeoutS(chThdSuspendTimeoutS) => 16 bytes
chSchGoSleepTimeoutS(chSchGoSleepTimeoutS) => 40 bytes
chVTDoSetI(chVTDoSetI) => 24 bytes
stStartAlarm(stStartAlarm) => 8 bytes
SUM => 224 bytes
So, there are potentially occur stack overflow in Thread1 function.
Environment
Version
Commit e407956
Issue details
While some detailed build configuration, There are potential stack overflow in thread function named Thread1
CentSDR/main.c
Line 22 in e407956
CentSDR/main.c
Line 1039 in e407956
In this line, Thread1 Allows 128 stack size.
However, after checking the stack using our internally developed tool, it might have 224 Bytes in with some detailed configurations.
Steps to produce
1. In Makefile, Add this line:
In 8 line..
This will help you automatically calculating stack size of each function.
2. Build centSDR normally, using this configurations:
makeNow we can get stack usage file (*.su) for each source file, So we can manually check stack size of each function.
In case of Thread1 :
There are large call stack with this flow:
Thread1(Thread1) => 24 bytes
tlv320aic3204_get_left_agc_gain(tlv320aic3204_get_left_agc_gain) => 32 bytes
i2cMasterTransmitTimeout (i2cMasterTransmitTimeout) => 40 bytes
i2c_lld_master_transmit_timeout(i2c_lld_master_transmit_timeout) => 40 bytes
chThdSuspendTimeoutS(chThdSuspendTimeoutS) => 16 bytes
chSchGoSleepTimeoutS(chSchGoSleepTimeoutS) => 40 bytes
chVTDoSetI(chVTDoSetI) => 24 bytes
stStartAlarm(stStartAlarm) => 8 bytes
SUM => 224 bytes
So, there are potentially occur stack overflow in Thread1 function.
Environment
Version
Commit e407956