Bugzilla – Bug 159
Infinite loop in packet metadata code for large packets.
Last modified: 2008-04-04 11:07:35 UTC
I've attached a test case, but when creating large packets (size > 16383) with Packet::EnableMetadata() there is a hang. If the EnableMetadata() is commented out, then there is no hang. If you step in gdb through the code, it appears to be stuck in an infinite loop. \dae Code---%<-------------------%<----------%<----------%<----------%<---------%< #include "ns3/packet.h" #include "ns3/ptr.h" #include <iostream> int main() { int size[] = {10, 100, 1000, 16000, 16300, 16350, 16383, 16384, 16390, 16400, 100000, 0}; // note: comment this out, and there is no hang. ns3::Packet::EnableMetadata(); for (int i = 0; size[i]; i++) { std::cout << "creating packet of size=" << size[i] << "...."; ns3::Ptr<ns3::Packet> p = ns3::Create<ns3::Packet> (size[i]); std::cout << "done." << std::endl; } } Compiled as%<---------------%<----------%<----------%<----------%<---------%< g++ -DNS3_ASSERT_ENABLE -DNS3_LOG_ENABLE -DDEBUG -Wall -Werror -g -O2 -I/.../ns-3-dev/build/debug -I/.../ns-3-dev/build/debug -I. -c -o packet_too_big.o packet_too_big.cc g++ -o packet_too_big packet_too_big.o -L/.../ns-3-dev/build/debug -lns3 -Wl,-rpath=/.../ns-3-dev/build/debug gdb output---%<-------------%<----------%<----------%<----------%<---------%< $ gdb packet_too_big GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu"... (gdb) run Starting program: /.../packet_too_big creating packet of size=10....done. creating packet of size=100....done. creating packet of size=1000....done. creating packet of size=16000....done. creating packet of size=16300....done. creating packet of size=16350....done. creating packet of size=16383....done. Program received signal SIGINT, Interrupt. 0x00002ad6f62a819e in ns3::PacketMetadata::AddSmall (this=0x61c598, item=0x7fffb4def610) at ../src/common/packet-metadata.cc:458 458 if (end - start >= 8 && (gdb) where #0 0x00002ad6f62a819e in ns3::PacketMetadata::AddSmall (this=0x61c598, item=0x7fffb4def610) at ../src/common/packet-metadata.cc:458 #1 0x00002ad6f62a4a84 in ns3::PacketMetadata::DoAddHeader (this=0x61c598, uid=0, size=16384) at ../src/common/packet-metadata.cc:722 #2 0x00002ad6f62a8493 in PacketMetadata (this=0x61c598, uid=7, size=16384) at ../src/common/packet-metadata.h:313 #3 0x00002ad6f62bdbb8 in Packet (this=0x61c570, size=16384) at ../src/common/packet.cc:84 #4 0x0000000000400e8f in ns3::Create<ns3::Packet, int> (a1=16384) at /.../ns-3-dev/build/debug/ns3/ptr.h:231 #5 0x0000000000400dec in main () at packet_too_big.cc:17
fixed in HEAD now. changeset ab1e9244ab41 thanks !