-
Couldn't load subscription status.
- Fork 3k
Description
I am testing the sample mbed-os-example-client with WiFi module esp8266 on target board NUMAKER_PFM_NUC472.
Target baord: NUMAKER_PFM_NUC472
mbed-os-example-client (SHA code: d22a0db)
mbed-os (SHA code: 9111aa4)
esp8266-driver (SHA code: 29d63ae2ee0a233e2fbd9577cdddc7661bb783d1)
After fixing some target related issues, it can work normally. For my development and debug requirement, I add printf calls in crypto related functions in mbed-os library. This will cause system crash sometimes and no message tells the cause. I try to export it to KEIL uvision project and check through debugger. Per debugger call stack, the cause is found out. The reduced call stack (from bottom to top) would be:
ESP8266Interface::eventcalled from serial interrupt handlerM2MConnectionHandlerPimpl::socket_eventcalled due to socket state changeM2MInterfaceImpl::socket_errorcalled asmemory_pool.allocfails inM2MConnectionHandlerPimpl::socket_event. Ifmemory_pool.allocsucceeds, no error._mutex_acquirefinally called and it causes Memory Management Fault because now it is in interrupt context
void M2MConnectionHandlerPimpl::socket_event()
{
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR,** true);
return;
}
task->pimpl = this;
......
}
I suggest better handling as event pool runs out such as below. Note M2MConnectionHandlerPimpl::socket_event is called in interrupt context.
- No such Memory Management Fault
- Message could be output to tell the cause