[omnetpp] Segmentation Fault

496 views
Skip to first unread message

Marco Gramaglia

unread,
Nov 26, 2007, 1:52:41 PM11/26/07
to omne...@omnetpp.org
Hi,
how it's possible that if I run my simulation I get a segmentation fault but if I run the simulation under Valgrind it ends correctly?
Could it be a problem in my C library?
Thanks
Marco



______________________________________________
¿Chef por primera vez?
Sé un mejor Cocinillas.
http://es.answers.yahoo.com/info/welcome
_______________________________________________
OMNeT++ Mailing List
options: http://lists.omnetpp.org/mailman/listinfo/omnetpp-l
archive: http://www.omnetpp.org/listarchive/index.php

Andreas Koepke

unread,
Nov 26, 2007, 2:38:02 PM11/26/07
to OMNeT++ Discussion List
No, one of your functions is messing up the call stack. (Most likely).
These bugs are hard to find.

Marco Gramaglia:

Marco Gramaglia

unread,
Nov 26, 2007, 4:57:55 PM11/26/07
to OMNeT++ Discussion List
and how i can debug?

----- Mensaje original ----
De: Andreas Koepke <koe...@tkn.tu-berlin.de>
Para: OMNeT++ Discussion List <omne...@omnetpp.org>
Enviado: lunes, 26 de noviembre, 2007 20:38:02
Asunto: Re: [omnetpp] Segmentation Fault

Marco Gramaglia

unread,
Nov 26, 2007, 4:57:31 PM11/26/07
to OMNeT++ Discussion List

Andreas Koepke

unread,
Nov 27, 2007, 3:38:00 AM11/27/07
to OMNeT++ Discussion List
1. Check your code carefully for anything that might corrupt your stack
in all of your functions. Size of arrays on your stack, access to
function local variables, pointers to stuff on stack, objects on
stack and their constructors...

2. Write stack guards (some variable at enter/leave of functions)

3. Often I find it easier to revise and rewrite the whole code ;-)

Best, Andreas

Marco Gramaglia:

Marco Gramaglia

unread,
Nov 27, 2007, 7:38:18 AM11/27/07
to OMNeT++ Discussion List
I don't understand.
I believe that Omnet sends copy of a message. But when i try to re-send a frame after a collision valgrind told me
==8743== Invalid read of size 4
==8743== at 0x805F189: CSMACAMacLayer::handleSendData() (CSMACAMacLayer.cc:244)
==8743== by 0x805FB66: CSMACAMacLayer::handleSelfMsg(cMessage*) (CSMACAMacLayer.cc:179)
==8743== by 0x406C96B: BasicLayer::handleMessage(cMessage*) (BasicLayer.cc:72)
==8743== by 0x41D0C5C: cSimulation::doOneEvent(cSimpleModule*) (in /home/marco/omnetpp/lib/libsim_std.so.3.3)
==8743== by 0x4179E0A: TCmdenvApp::simulate() (in /home/marco/omnetpp/lib/libcmdenv.so.3.3)
==8743== by 0x417A660: TCmdenvApp::run() (in /home/marco/omnetpp/lib/libcmdenv.so.3.3)
==8743== by 0x4161F38: main (in /home/marco/omnetpp/lib/libenvir.so.3.3)
==8743== Address 0x46E8B20 is 0 bytes inside a block of size 120 free'd
==8743== at 0x4021096: operator delete(void*) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==8743== by 0x4058CA6: MacPkt::~MacPkt() (MacPkt_m.cc:87)
==8743== by 0x41E3D52: cMessage::~cMessage() (in /home/marco/omnetpp/lib/libsim_std.so.3.3)
==8743== by 0x40552EA: AirFrame::~AirFrame() (AirFrame_m.cc:88)
==8743== by 0x40E9BB6: SnrDecider::handleLowerMsg(AirFrame*, std::list<SnrListEntry, std::allocator<SnrListEntry> > const&) (SnrDecider.cc:63)
==8743== by 0x406B860: BasicDecider::handleMessage(cMessage*) (BasicDecider.cc:62)
==8743== by 0x41D0C5C: cSimulation::doOneEvent(cSimpleModule*) (in /home/marco/omnetpp/lib/libsim_std.so.3.3)
==8743== by 0x4179E0A: TCmdenvApp::simulate() (in /home/marco/omnetpp/lib/libcmdenv.so.3.3)
==8743== by 0x417A660: TCmdenvApp::run() (in /home/marco/omnetpp/lib/libcmdenv.so.3.3)
==8743== by 0x4161F38: main (in /home/marco/omnetpp/lib/libenvir.so.3.3)
Does the SnrEval delete a packet and when i try to re-send i catch a SegFault?
The line in handleSendData is where i try to do sendDown with te frame in te queue.
Do i have to write a SnrEval which doesn't delete frame if there is a collision or i have to save dup() of my packet in the queue?
And what about the copy of the frame?
Thanks
Marco

----- Mensaje original ----
De: Andreas Koepke <koe...@tkn.tu-berlin.de>
Para: OMNeT++ Discussion List <omne...@omnetpp.org>

Enviado: martes, 27 de noviembre, 2007 9:38:00

Andreas Koepke

unread,
Nov 27, 2007, 7:48:34 AM11/27/07
to OMNeT++ Discussion List
Not completely true. send is the notable exception: it transfers the
ownership of the object. You should make a copy yourself.

Marco Gramaglia:

Reply all
Reply to author
Forward
0 new messages