App crashes when deleting an LWM2M object using mbed-client on mbed-os

How do can I delete an object and its instance while mbed client is connected to the device server?

Currently I have a class that creates an object in the constructor and I register it with mbed client. I would also like to delete this object when the destructor is called. I’m trying the following:

In the constructor:

object = M2MInterfaceFactory::create_object(name);
instance = object->create_object_instance();

In the destructor:

// delete object;

The above code works but the object is never removed from memory.

If I uncomment the line to call the object’s destructor then my application crashes. I used mbed-trace to see if there are any error messages, but couldn’t find anything. Here is the output of the log from the call to the destructor until the app crashes.

I’m using a Nucleo-F401RE with mbed-os 5.4.1.

Is your resource , in question, under observation ? There can be some issue while deleting objects, if they are under observation, We will investigate this issue to find the root cause and get the fix.