Page 1 of 1

(RTOS_SDK) mbedtls_ssl_write low memory issue

Posted: Wed Jul 05, 2017 11:45 am
by gustavomassa
Hello,

The function mbedtls_ssl_write get stuck forever when there is low heap memory, about 3-4kb of heap. The ssl_write will block forever until you reset the device, it only occurs when the heap memory is low. The interrupts still works while the write is blocking forever. Please investigate.

File -> RTOS_SDK\third_party\mbedtls\library\ssl_tls.c
Function -> int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len )

Digging a little bit more on the issue, I've added vPortEnterCritical() and vPortExitCritical between the "ssl_write" call, then the code always crashes and prints ShowCritical:1 message on the uart.

Re: (RTOS_SDK) mbedtls_ssl_write low memory issue

Posted: Thu Jul 06, 2017 12:41 pm
by pratik
So this is an RTOS SDK issue I guess? Because mbedTLS on nonOS SDK works fine near minimum heap usage limits too, as long as it can allocate memory for operations. And if it cannot, a memory allocation error is generated (and sending fails).
Which version of SDK are you using? Can you attach a log?
I would like to know if this failure occurs during a callback or just before a callback.

For temporarily fixing this, try to check free heap before calling the function that causes failure with low heap space.

Re: (RTOS_SDK) mbedtls_ssl_write low memory issue

Posted: Thu Jul 06, 2017 2:38 pm
by Her Majesty
Without enough memory, you can do nothing.
Which version of ESP8266 RTOS SDK are you using? Maybe you can try the latest one.

Re: (RTOS_SDK) mbedtls_ssl_write low memory issue

Posted: Sat Jul 15, 2017 2:36 am
by ememberus
Without enough memory, you can do nothing.

Running an infinite loop and waiting gives developers no clue to what is wrong and how to resolve the issue.
In case of low memory, you can return an error code or message indicating this explicitly.
Silent default behavior will poison everything and should be completely eliminated.