OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000445OMNeT++simulation kernelpublic2011-11-17 10:232011-11-17 10:23
michael 
 
normalminoralways
newopen 
4.2rc1 
 
0000445: Segmentation fault on deleting message
Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.)
    27 cOwnedObject::~cOwnedObject() d:\Tools\omnetpp-4.2rc2\src\sim\cownedobject.cc:111 0x6ba34a59
    26 cMessage::~cMessage() d:\Tools\omnetpp-4.2rc2\src\sim\cmessage.cc:102 0x6ba227a2
    25 cPacket::~cPacket() d:\Tools\omnetpp-4.2rc2\src\sim\cmessage.cc:396 0x6ba23cf5
    24 NetwPkt::~NetwPkt() d:\...\MiXiM\src\base\messages\NetwPkt_m.cc:47 0x684e040c
    23 NetwPkt::~NetwPkt() d:\...\MiXiM\src\base\messages\NetwPkt_m.cc:49 0x684e0437
    22 c_fctpointer_wrapper<c_netw_layer_timing>::~c_fctpointer_wrapper() d:\...\susan\base\modules\simpleTiming\c_simple_timing.h:81 0x628511f8
    21 c_fctpointer_wrapper<c_netw_layer_timing>::~c_fctpointer_wrapper() d:\...\susan\base\modules\simpleTiming\c_simple_timing.h:84 0x628511ad
    20 c_delete_messages_fctor::operator() d:\...\susan\base\modules\simpleTiming\c_simple_timing.cc:69 0x628534a7
    19 std::for_each<std::_Rb_tree_const_iterator<cMessage*>, c_delete_messages_fctor>() d:\tools\omnetpp-4.2rc2\mingw\lib\gcc\mingw32\4.6.1\include\c++\bits\stl_algo.h:4302 0x6285e000
    18 c_simple_timing::~c_simple_timing() d:\...\susan\base\modules\simpleTiming\c_simple_timing.cc:144 0x62849c9f
    17 c_simple_timing::~c_simple_timing() d:\...\susan\base\modules\simpleTiming\c_simple_timing.cc:146 0x62849d51
    16 cModule::deleteModule() d:\Tools\omnetpp-4.2rc2\src\sim\cmodule.cc:1112 0x6ba2c7c8
    15 cSimpleModule::deleteModule() d:\Tools\omnetpp-4.2rc2\src\sim\csimplemodule.cc:346 0x6ba3d337
    14 cModule::~cModule() d:\Tools\omnetpp-4.2rc2\src\sim\cmodule.cc:93 0x6ba28a55
    13 cCompoundModule::~cCompoundModule() d:\Tools\omnetpp-4.2rc2\src\sim\ccompoundmodule.cc:36 0x6ba0ba1c
    12 cCompoundModule::~cCompoundModule() d:\Tools\omnetpp-4.2rc2\src\sim\ccompoundmodule.cc:38 0x6ba0ba47
    11 cModule::deleteModule() d:\Tools\omnetpp-4.2rc2\src\sim\cmodule.cc:1112 0x6ba2c7c8
    10 cModule::~cModule() d:\Tools\omnetpp-4.2rc2\src\sim\cmodule.cc:93 0x6ba28a55
    9 cCompoundModule::~cCompoundModule() d:\Tools\omnetpp-4.2rc2\src\sim\ccompoundmodule.cc:36 0x6ba0ba1c
    8 cCompoundModule::~cCompoundModule() d:\Tools\omnetpp-4.2rc2\src\sim\ccompoundmodule.cc:38 0x6ba0ba47
    7 cModule::deleteModule() d:\Tools\omnetpp-4.2rc2\src\sim\cmodule.cc:1112 0x6ba2c7c8
    6 cSimulation::deleteNetwork() d:\Tools\omnetpp-4.2rc2\src\sim\csimulation.cc:463 0x6ba411b1
    5 Tkenv::run() d:\Tools\omnetpp-4.2rc2\src\tkenv\tkenv.cc:294 0x6478221b
    4 EnvirBase::run() d:\Tools\omnetpp-4.2rc2\src\envir\envirbase.cc:245 0x6dec4415
    3 setupUserInterface() d:\Tools\omnetpp-4.2rc2\src\envir\startup.cc:235 0x6dec27a4
    2 evMain() d:\Tools\omnetpp-4.2rc2\src\envir\evmain.cc:37 0x6dec2ce4
    1 main() main.cc:27 0x004013e0

The debugger holds here:
cOwnedObject::~cOwnedObject()
{
#ifdef DEVELOPER_DEBUG
    objectlist.erase(this);
#endif

    if (ownerp)
        ownerp->ownedObjectDeleted(this); //!SEGMENTATION FAULT!

    // statistics
    live_objs--;
}

I use a own module c_simple_timing which inserts a specific (compute time) delay for specific messages, for that the module wrapps the message which shall be delayed and the function which shall be called after delay.

The segmentation fault occured only on finish simulation in the destructors:

        ~c_fctpointer_wrapper()
        {
            if (pMsgToSend != NULL) {
                // OK, the message was not called so that we must free it here,
                // otherwise we got memory leaks
                delete pMsgToSend; //!The origin of SEGMENTATION_FAULT!
                pMsgToSend = NULL;
            }
        }

c_simple_timing::~c_simple_timing()
{
    std::for_each( vPendingMessages.begin(), vPendingMessages.end(), c_delete_messages_fctor(this) );
    vPendingMessages.clear();
}

//vPendingMessages will be created as follow
cMessage* pWaitMsg = new cMessage ("Computing...", WAIT_COMPUTE);
//attach caller Object to Timer Message
pWaitMsg->addObject(new c_fctpointer_wrapper<T>(pCaller, fctPSend, pMsg));
// push it on stack
vPendingMessages.insert(pWaitMsg);
// schedule self message for Timing
scheduleAt(simTime() + dTimeToWait, pWaitMsg);

Is it possible that the wrapped-message is deleted twice!? How can I check this?
No tags attached.
Issue History
2011-11-17 10:23michaelNew Issue

There are no notes attached to this issue.