Arm Mbed and Pelion Device Management support forum

Std::string in struct call Rtos Mutex Error

Hello. I have a problem with simple code:

class InternalMemory : public FlashIAPBlockDevice
{
    struct Settings
    {
        bool isDHCP;
        std::string ip;
        std::string netmask;
        std::string gateway;
        std::string label;
    };
private:
Settings *settings;
}

InternalMemory::InternalMemory(uint32_t address, uint32_t size) : FlashIAPBlockDevice(address, size)
{
    auto settings = new Settings ();
   //next line - ok
    settings->isDHCP = false;
   //Next line call  MbedOS Error
    settings->ip = "192.168.1.4";
}

main(){
    auto memory = new InternalMemory(ADDRESS, SIZE);
}

Error out:

++ MbedOS Error Info ++

Error Status: 0x80010133 Code: 307 Module: 1

Error Message: Mutex: 0x2000746C, Not allowed in ISR context

Location: 0x8024E65

Error Value: 0x2000746C

Current Thread: main Id: 0x20005588 Entry: 0x8024D2F StackSize: 0x1000 StackMem: 0x20006438 SP: 0x2002FE40

For more info, visit: https://mbed.com/s/error?error=0x80010133&tgt=NUCLEO_F429ZI

-- MbedOS Error Info --

I don’t understand, why calling Rtos Mutex Error?

HI @MasterLufier
I have tried running your code on my K64F board, and didn’t get an issue.
As for your question about Mutex, even if you specifically don’t use a Mutex, mutexes are used within the system.
For example, when you allocate the settings structure, __rtos_malloc_lock() will be be called, and your interrupts are probably enabled.
As shown in https://os.mbed.com/questions/86903/Error-Message-Mutex-0x2000168C-Not-allow/:
The interupts can be disabled by these calls for example check bellow, but this will not help you because of mutex…

#### Disable/Enable Interupts
 __disable_irq();   
 // do something magic
 __enable_irq();

Regards,
Mbed Support
Ron

I change my struct to:

struct Settings
    {
        bool isDHCP{};
        char ip[16];
        char netmask[16];
        char gateway[16];
        char label[30];
    };

and it’s work correctly. It doesn’t convenient, but it works. Thanx.

1 Like