I have created an http server following the example for server1 under FreeRTOS and Lwip running on a STM32H753 using the Stm32CubeIDE. Everything seem to work correctly, however, I am experiencing a small memory leak over each successive TLS connection of 160 bytes. It is obvious that I must not be freeing a context, but as I am following the example very closely, except for running the code in a FreeRTOS thread, I must be missing something fundemental. Has anyone on this list experienced a similar issue or have any ideas on how to debug it?
On 25/04/2023 15:31, Malcolm Bugler via mbed-tls wrote:
I have created an http server following the example for server1 under FreeRTOS and Lwip running on a STM32H753 using the Stm32CubeIDE. Everything seem to work correctly, however, I am experiencing a small memory leak over each successive TLS connection of 160 bytes. It is obvious that I must not be freeing a context, but as I am following the example very closely, except for running the code in a FreeRTOS thread, I must be missing something fundemental. Has anyone on this list experienced a similar issue or have any ideas on how to debug it?
Hi Malcolm,
In our continuous integration, we use Asan to check for memory leaks when running tests in many different configuration. It's of course possible that we missed a case.
Asan is good for locating as well as detecting leaks, but it isn't practical on a microcontroller. I don't know what facilities FreeRTOS offers for tracing memory allocations.
If you can't figure out what those 160 bytes are, I happen to have a tool that might help: in https://github.com/Mbed-TLS/mbedtls/pull/5234 there's a script that reports the layout of structures, so you can look for the one(s) that are 160 bytes. It's can be hard to get it to work when cross-compiling (you have to pass library headers that compile, and if something goes wrong there's no way to know what), but it might help if you can't figure out the structure otherwise.
Hope this helps,
mbed-tls@lists.trustedfirmware.org