Hi Сергей Борщ,
I would like to explain my situation clearer.
In the function udp_client_send() defined by me, I used mutex.
I called the udp_client_send() function separately in two threads in my RTOS.
Thread A runs every 1ms and calls the udp_client_send() function 100 times per run.
Thread A runs every 1s and calls the udp_client_send() function 100 times per run.
The length of data sent by UDP is 5000 bytes.
Because of the mutex, the program will only pbuf_alloc a new pbuf when the last pbuf is free.
The program is still stuck though I used mutex to make sure only one pbuf is allocated at one time.
The"assert stuck line: p!=NULL" is inside the pbuf_free() function.
You can see the assert line at this link: https://github.com/RT-Thread/rt-thread/blob/a0ca06b4994d7c4a423b03f272c2c2a86a7bd07f/components/net/lwip/lwip-2.1.2/src/core/pbuf.c#L732
Now I just don't know how this stuck problem is triggered, and I don't know how to solve it.