[SOLVED] What's that? WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!

MalteJ
Posts: 62
Joined: Wed Sep 21, 2016 10:26 pm

[SOLVED] What's that? WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!

Postby MalteJ » Sat Mar 11, 2017 11:33 am

Hi,

I have an application with multiple open network sockets and I want to do an esp_restart() after I have done an OTA update.
Problem is the ESP does not restart, but just stops WiFi and outputs:

Code: Select all

I (59383) wifi: state: run -> init (0)
I (59383) wifi: pm stop, total sleep time: 0/5686139

I (59383) wifi: n:6 0, o:6 1, ap:255 255, sta:6 1, prof:8
I (59393) EVENT: SYSTEM_EVENT_STA_DISCONNECTED
WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!
I (61393) EVENT: SYSTEM_EVENT_STA_STOP
What is happening here?
I suspect there are some strange left-overs from something?
When I use my OTA code with the esp_restart() call in a new clean project I don't get this error and the esp restarts as it should. So what could lead to this behavior and prevent a restart?

Thank you!

Best,
Malte
Last edited by MalteJ on Sat Mar 11, 2017 2:35 pm, edited 1 time in total.

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

Re: What's that? WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!

Postby rudi ;-) » Sat Mar 11, 2017 1:16 pm

Code: Select all


#define MAX_POLL_CNT 100
#define PER_POLL_DELAY 20


Deallocates a mailbox. If there are messages still present in the
mailbox when the mailbox is deallocated, it is an indication of a
programming error in lwIP and the developer should be notified.
best wishes
rudi ;-)

https://github.com/espressif/esp-idf/bl ... rch.c#L360

Code: Select all

void
sys_mbox_free(sys_mbox_t *mbox)
{
#define MAX_POLL_CNT 100
#define PER_POLL_DELAY 20
  uint16_t count = 0;
  bool post_null = true;

  LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: set alive false\n"));
  (*mbox)->alive = false;

  while ( count++ < MAX_POLL_CNT ){ //ESP32_WORKAROUND
    LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:try lock=%d\n", count));
    if (!sys_mutex_trylock( &(*mbox)->lock )){
      LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:get lock ok %d\n", count));
      sys_mutex_unlock( &(*mbox)->lock );
      break;
    }

    if (post_null){
      LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null to mbox\n"));
      if (sys_mbox_trypost( mbox, NULL) != ERR_OK){
        ESP_STATS_INC(esp.free_mbox_post_fail);
        LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox fail\n"));
      } else {
        post_null = false;
        LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox ok\n"));
      }
    }

    if (count == (MAX_POLL_CNT-1)){
      printf("WARNING: mbox %p had a consumer who never unblocked. Leaking!\n", (*mbox)->os_mbox);
    }
    sys_delay_ms(PER_POLL_DELAY);
  }

  LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free:free mbox\n"));

  if (uxQueueMessagesWaiting((*mbox)->os_mbox)) {
    xQueueReset((*mbox)->os_mbox);
    /* Line for breakpoint.  Should never break here! */
    __asm__ volatile ("nop");
  }

  vQueueDelete((*mbox)->os_mbox);
  sys_mutex_free(&(*mbox)->lock);
  free(*mbox);
  *mbox = NULL;
}

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

MalteJ
Posts: 62
Joined: Wed Sep 21, 2016 10:26 pm

Re: What's that? WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!

Postby MalteJ » Sat Mar 11, 2017 1:49 pm

Yeah, I've seen this, but I still don't know what to do?
When is this mailbox used? When will it be blocked and what can I do about it?

Best,
Malte

MalteJ
Posts: 62
Joined: Wed Sep 21, 2016 10:26 pm

Re: What's that? WARNING: mbox 0x3ffda484 had a consumer who never unblocked. Leaking!

Postby MalteJ » Sat Mar 11, 2017 2:15 pm

Oh, I found my mistake:

esp_restart() does three calls:

Code: Select all

esp_wifi_stop();
vTaskSuspendAll();
esp_restart_noos();
My application breaks during esp_wifi_stop()
The reason is when I receive a SYSTEM_EVENT_STA_DISCONNECTED event I kill my OTA task. But the OTA task is responsible for executing the esp_restart() function. So that's why everything is stopping :lol:

Thank you!

Malte

Who is online

Users browsing this forum: noweare and 197 guests