esp-modbus icon indicating copy to clipboard operation
esp-modbus copied to clipboard

Fix for a deadlock startup problem where "port_serial_task" is suspended and never resumed. (IDFGH-14964)

Open klew opened this issue 8 months ago • 2 comments

port_serial_task is started with "enable" set to false. Then in main loop it checked if "enable" was false and called vTaskSuspend. Another task, which called mbc_slave_create_serial and mbc_slave_start, may cause that mb_port_ser_enable is called between checking "enable" flag and vTaskSuspend in port_serial_task. As a result, mb_port_ser_enable calls vTaskResume on a non-suspended task. Then control is given back to port_serial_task, which calls vTaskSuspend and stucks in this state forever.

Fix is replacing vTaskSuspend and vTaskResume with a semaphore based ulTaskNotifyWait and vTaskNotifyGive. Additionally "enable" flag is checked in while loop instead of "if".

klew avatar Mar 27 '25 13:03 klew

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 27 '25 13:03 CLAassistant

@klew,

Thank you for contribution. Looks good for now. I will take a look a bit later to check and apply.

alisitsyn avatar Apr 01 '25 07:04 alisitsyn