Assertion failed: id error, how to proceed further?

Hello everyone,

I am a beginner to MbedOS programming and I am developing a program that controls a small robot for university. I have a custom board that has a STM32H743ZIT6 MCU and a STM32H743ZI2 development board. After about one minute or so, no matter what parts of the program I am executing, it crashes, with the following error message:

++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: id
Location: 0x803A8F3
File: ./mbed-os/events/include\events/Event.h+207
Error Value: 0x0
Current Thread: rtx_idle Id: 0x24006D8C Entry: 0x803D411 StackSize: 0x380 StackMem: 0x24006E58 SP: 0x2407FEC4 
For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=NUCLEO_H743ZI2
-- MbedOS Error Info --

I have no idea what causes this, it seems that no matter what I do this always happens, how should I proceed further. The error message is very vague and does not offer me a lot of information. I am at a complete loss. Any ideas would be greatly appreciated.

Thanks from a new member of this community,
Alexandru

Hello Alex,

the error tells you where was the Assert triggered - File: ./mbed-os/events/include\events/Event.h+207
So try check this description. It seems like you need to check a thread stack size or something similar (just only Tip).

// just for demonstration of a simple use case
#include "mbed.h"
 
DigitalOut* myled;
InterruptIn button(BUTTON1);

void pressed(){
    // that is wrong and it will triger MBED_ASSERT in the loop
    myled = nullptr;
}

int main(){
    printf("MBED_ASSERT test!\n");

    button.rise(callback(pressed));
    myled = new DigitalOut(LED1);

    while(1) {
        MBED_ASSERT(myled);
        *myled = !*myled;
        thread_sleep_for(500);
    }
}

BR, Jan

Alright, so at first I thought that @JohnnyK was right and one of the event queues in my program might be running out of memory, but I added a counter to the culprit to see how many callbacks were created, and even if I decrease the Event queue size by 100 times, the program still crashes after ~320 callbacks. I am at a complete loss. Same if I am doubling the thread stack size.

More context, I have multiple event queues in this program that each do their own independent tasks. One of them checks the values of some sensors periodically when given such command. If this command is never given, i.e. this singleton is never created then the program does not crash. All other EventQueues work great. However, when I start checking sensor values the program crashes after the SensorChecker::update() is called 328~ times. My code is as such:

SensorChecker* SensorChecker::get_instance() {
  if (instance == nullptr) {
    instance = new SensorChecker();
  }
  return instance;
}

void SensorChecker::start() {
    if (!running) {
  tr_info("Started");
  ticker.attach(ThreadManager::event_queue.event(
      callback(this, &SensorChecker::update)), 250ms);
    running = true;
    }
    else {
        tr_info("Method to start was called, but it's already running! ")
    }
}

void SensorChecker::stop() {
  if (running) {
  ticker.detach();
  running = false;
  tr_info("Stopped ");
  } else {
      tr_warn("A method to stop was called, but it is not running! ");
  }
}

void SensorChecker::update() {
    //update_position();
    // update_time();
    //update_speed();
    // update_acc();
}

An interesting thing is that I have commented out all actual functionality in the SensorChecker::update() method and even if it’s a completely empty void method the program still crashes. Another remark is that if I start the SensorChecker and I call the method stop right after the program will still crash after the same amount of time.