简体   繁体   中英

OMNet++ | Simulation Runtime error : Object is currently in (omnetpp::cEventHeap)simulation.scheduled-events

I'm pretty new in using OMNeT++ IDE and I would like to use some "infinite array" to store some data in my message. My code is fine without any error but when I'm launching my simulation, it just stops instantaneously. I've checked in debug mod and it does launch but when I'm supposed to use this message I got the following runtime error:

A runtime error occured: Object is currently in (omnetpp::cEventHeap)simulation.scheduled-events, it cannot be deleted. If this error occurs inside omnetpp::cEventHeap, it needs to be changed to call drop() before it can delete that object. If this error occurs inside omnetpp::cEventHeap's destructor and is a class member, omnetpp::cEventHeap needs to call drop() in the destructor -- in module...

This error looks to appear only when I'm just sending the message in another module.

After further inspections, I've found that it's due to the fact that I'm using "infinite arrays":

My message implementation .msg

packet Msg_event_data
{
    string name_event_data;
    int clock;
    int map_left_column[]; //infinite array n°1
    int map_right_column[]; //infinite array n°2
}

This is what I got from the debugger: debugger report

From all of this, I suppose that I should use the drop() function in the destructor method of my message but I'm not sure and I haven't achieved to use it successfully with these infinite arrays.

This my message destructor method :

Msg_event_data::~Msg_event_data()
{
   delete[] this->map_left_column; //auto generated by omnet++
   delete[] this->map_right_column;//auto generated by omnet++
}

Could you give a hand on this please? I'm quite stuck with this...

PS: I'm using the actual latest version of OMNET++ on Win-64 OS with Intel-I7. (on 07/30/2020)

This has nothing to do with 'infinite' arrays or whatever. The reason for the error message is that you are trying to delete a packet which is already scheduled in the message queue. It means that you created a packet (Masg_event_data) and after sending it out with a send() call, you have kept its pointer and then reused that pointer somewhere else in your code and tried to delete it. After you pass a message/packet to send() or scheduleAt() you should forget all pointers to it and should never ever dereference it. The next time when you can work with this packet when the message is handled to the destination module's handleMessage() function. At that point it is removed from the event queue and you are free to delete it.

This error happens in the TDMA::sendMessageBurst() function according to the debugger stack-trace. You are deleting a packet in function called sendMessageBurst ? This is semantically surely incorrect, but without seeing and understanding the above function body, it's not possible to tell how/why... So, at a minimum, the TDMA::sendMessageBurst() and the TDMA::initialize()() code should be included in this question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM