Random corruption of FreeRTOS+Tcp on STM32F107

FreeRTOS community,
I met a stability issue with FreeRTOS+Tcp on STM32F107. The behavior is random, sometimes on BufferAllocation_2.c, Line 251,

  	/* Allocate storage of exactly the requested size to the buffer. */
  	configASSERT( pxReturn->pucEthernetBuffer == NULL );

Sometimes on the alignment check in pxPacketBuffer_to_NetworkBuffer. And most often, just hard fault. I believe this is caused
by some memory corruption.
The problem rises randomly, sometimes several hours, sometimes in about 20 minutes. When the network is not working, the issue
is not observed.
I run a just UDP server in the application. However, the server may spend quite some time handling some request. Thus it may
not handle the network traffic from some time(maybe 30 seconds). I know the design is bad. But will that cause the stability
problem above?
I am running Release 10.4.0.
BR
/li

Lizhang, I’m not sure which driver you are using, but could you try out the change that I recently made in PR 144 ?
That may well solve the problem that you encounter. Can you please report back her?
Thanks.

Hein,
Thank you. If I understand it correctly, the change is alreayd merged to the master branch. right?
BR
/Li

Yes it is merged into the main branch. But I think that you should make the same change in your STM32F1xx driver, could that be?

Hein,
Thank you for your info.
I still got crash report after up-merge. So I applied the changes from https://community.st.com/s/question/0D50X0000C4Nk4GSQS/bug-missing-compiler-and-cpu-memory-barriers.
And since it is related to compiler, I remove the optimization for the ethernet driver.
I am using IAR compiler, so it may not be a problem for others.
After the two changes, the tester told me it was stable for several days. As this is my part-time job, and the issue is not easy to re-produce, I didn’t go further to check which one actually work.
BR
/Li