EmbeddedRPC / erpc

Embedded RPC
https://github.com/EmbeddedRPC/erpc/wiki
BSD 3-Clause "New" or "Revised" License
704 stars 202 forks source link

[BUG] eRPC as both client and server on Threadx OS doesn't work #387

Open sujanpepolla79 opened 11 months ago

sujanpepolla79 commented 11 months ago

Describe the bug

Hello, I am using eRPC on STM32H753 processor on Threadx OS. eRPC works fine if I use it as client or server but code crashes at erpc_framed_transport.cpp at Mutex::Guard lock(m_sendLock) in send() function call when arbitrator client tries to send message. The same code works good on FreeRTOS i.e I am able to use eRPC as both client and server on STM32. I am using ARM CMSIS UART as transport layer on STM32 and the other end Linux ubuntu PC is using eRPC on serial transport layer. Arbitrator client thread on Threadx OS environment crashes at Mutex::Guard lock(m_sendLock). Two threads have been created on Threadx and one thread is used as server and the second thread is used as client. The server thread starts first and client thread starts later.

To Reproduce

Create two threads on Threadx and use one thread as server and the other thread as client. Code crashes at Mutex::Guard lock receive/send call in erpc_framed_transport.cpp when second thread tries to send/receive message. This issue is observed only on Threadx OS. Initialize arbitrator client and server and create two threads. Use one thread as server and second one as client. Start server thread first and after some delay start the client thread Send message from client thread. No need to run eRPC on linux PC on the other end to reproduce this issue Code crashes at Mutex::Guard lock(m_sendLock) in erpc_framed_transport.cpp **Expected behavior** Client thread shall able to send notifications . m_sendlock shouldn't block the call since this mutex is being used only by client thread **Screenshots**

erpc_server_t server; erpc_transport_t arbitrator; erpc_transport_t transport = erpc_transport_cmsis_uart_init((void*)&Driver_USART4);

/ MessageBufferFactory initialization / erpc_mbf_t message_buffer_factory = erpc_mbf_dynamic_init();

erpc_arbitrated_client_init(transport, message_buffer_factory, &arbitrator);

server = erpc_server_init(arbitrator,message_buffer_factory); //Create server and client threads

Server thread: erpc_server_run(server);

Client thread: //send message(notification) function_call(true); Desktop (please complete the following information):

Additional context

github-actions[bot] commented 11 months ago

Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.

sujanpepolla79 commented 11 months ago

Hi eRPC, Any update? Do you accept this as bug?

Hadatko commented 11 months ago

Hi @sujanpepolla79 , we are not authors of this code. This come from community. We don't have ability to fix it by ourself. Could you create PR with bugfix?