Bugzilla – Bug 483
"Corrupted double-linked list error" when creating a Socket
Last modified: 2009-02-02 10:26:22 UTC
I am writting an application-level port of the Pastry DHT. The Application main class (properly registered as an NS3 object) has a pointer to a "Pinger" class that handles the distance metric functionality between the nodes. Upon initialization of the Pinger class, a Ptr to the node the application resides on (fetched by GetNode()) is passed to the pinger, and later on used as the "node" argument when creating a socket, inside the pinger, as follows: Ptr<Socket> currentSocket = Socket::CreateSocket(m_node, TypeId::LookupByName ("ns3::UdpSocketFactory")); However, upon execution, and when trying to request a socket from the node stack, a "Corrupted double-linked list" error pops up. The GDB backtrace is the following: (gdb) backtrace #0 0xb7f77410 in __kernel_vsyscall () #1 0xb74da085 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0xb74dba01 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0xb7512b7c in ?? () from /lib/tls/i686/cmov/libc.so.6 #4 0xb7519149 in ?? () from /lib/tls/i686/cmov/libc.so.6 #5 0xb751aedd in ?? () from /lib/tls/i686/cmov/libc.so.6 #6 0xb751ccad in malloc () from /lib/tls/i686/cmov/libc.so.6 #7 0xb76e7447 in operator new () from /usr/lib/libstdc++.so.6 #8 0xb7b83868 in __gnu_cxx::new_allocator<ns3::Ptr<ns3::Packet> >::allocate (this=0xbfc02020, __n=128) at /usr/include/c++/4.2/ext/new_allocator.h:91 #9 0xb7b838a5 in std::_Deque_base<ns3::Ptr<ns3::Packet>, std::allocator<ns3::Ptr<ns3::Packet> > >::_M_allocate_node (this=0xbfc02020) at /usr/include/c++/4.2/bits/stl_deque.h:430 #10 0xb7b83a72 in std::_Deque_base<ns3::Ptr<ns3::Packet>, std::allocator<ns3::Ptr<ns3::Packet> > >::_M_create_nodes (this=0xbfc02020, __nstart=0x8284404, __nfinish=0x8284408) at /usr/include/c++/4.2/bits/stl_deque.h:526 #11 0xb7b83b8b in std::_Deque_base<ns3::Ptr<ns3::Packet>, std::allocator<ns3::Ptr<ns3::Packet> > >::_M_initialize_map (this=0xbfc02020, __num_elements=0) at /usr/include/c++/4.2/bits/stl_deque.h:500 #12 0xb7b83c8f in _Deque_base (this=0xbfc02020, __a=@0xbfc0204f, __num_elements=0) at /usr/include/c++/4.2/bits/stl_deque.h:385 #13 0xb7b83ce4 in deque (this=0xbfc02020, __a=@0xbfc0204f) at /usr/include/c++/4.2/bits/stl_deque.h:684 #14 0xb7c0f9d6 in UdpSocketImpl (this=0x82873e8) at ../src/internet-stack/udp-socket-impl.cc:64 #15 0xb7bdbd2b in ns3::CreateObject<ns3::UdpSocketImpl> (attributes=@0xbfc020cc) at debug/ns3/object.h:398 #16 0xb7bdc3eb in ns3::CreateObject<ns3::UdpSocketImpl> (n1=@0xbfc021e8, v1=@0xbfc021b8, n2=@0xbfc021e4, v2=@0xbfc021b0, n3=@0xbfc021e0, v3=@0xbfc021a8, n4=@0xbfc021dc, v4=@0xbfc021a0, n5=@0xbfc021d8, v5=@0xbfc02198, n6=@0xbfc021d4, v6=@0xbfc02190, n7=@0xbfc021d0, v7=@0xbfc02188, n8=@0xbfc021cc, v8=@0xbfc02180, n9=@0xbfc021c8, v9=@0xbfc02178) at debug/ns3/object.h:463 #17 0xb7bda2bb in ns3::UdpL4Protocol::CreateSocket (this=0x806ee68) at ../src/internet-stack/udp-l4-protocol.cc:99 #18 0xb7c380e3 in ns3::UdpSocketFactoryImpl::CreateSocket (this=0x806eea8) at ../src/internet-stack/udp-socket-factory-impl.cc:44 #19 0xb7b8c4a1 in ns3::Socket::CreateSocket (node=@0xbfc0234c, tid=@0xbfc02360) at ../src/node/socket.cc:49 #20 0xb7ca5669 in ns3::NS3PastryNodePinger::MeasureDistance (this=0x807da00, handleIn=@0x828a2e0) at ../src/applications/NS3PastryNode/NS3PastryNodePinger.cc:43 #21 0xb7ca9b00 in ns3::NS3PastryNode::PingAllNodes (this=0x807a188) at ../src/applications/NS3PastryNode/NS3PastryNode.cc:364 #22 0xb7ca9832 in Notify (this=0x808e468) at debug/ns3/make-event.h:88 #23 0xb7acee62 in ns3::EventImpl::Invoke (this=0x808e468) at ../src/simulator/event-impl.cc:39 #24 0xb7ae94cd in ns3::DefaultSimulatorImpl::ProcessOneEvent (this=0x8067c20) at ../src/simulator/default-simulator-impl.cc:120 #25 0xb7ae9523 in ns3::DefaultSimulatorImpl::Run (this=0x8067c20) at ../src/simulator/default-simulator-impl.cc:150 #26 0xb7ad7bf3 in ns3::Simulator::Run () at ../src/simulator/simulator.cc:151 #27 0x0804e310 in RunSimulation () at ../scratch/PastryTesting.cc:274 #28 0x0804e4d2 in main () at ../scratch/PastryTesting.cc:286 If there is any other info required, feel free to contact me!
You are corrupting memory in one way or another. The best way to figure out who corrupted the memory is to run your program with valgrind.
Can you post a patch (or group of files) of your changes so that we may run your code? I'm willing to help you debug your issue.