Skip to content

Better handling for out of event pool #2606

Closed
@ccli8

Description

@ccli8

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:

  1. ESP8266Interface::event called from serial interrupt handler
  2. M2MConnectionHandlerPimpl::socket_event called due to socket state change
  3. M2MInterfaceImpl::socket_error called as memory_pool.alloc fails in M2MConnectionHandlerPimpl::socket_event. If memory_pool.alloc succeeds, no error.
  4. _mutex_acquire finally 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.

  1. No such Memory Management Fault
  2. Message could be output to tell the cause

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions