New issue 60 by kyle.creyts: analyzing packet causes memory leak
http://code.google.com/p/dpkt/issues/detail?id=60
What steps will reproduce the problem?
1. open packet with dpkt.pcap.Reader
2. push it into dpkt.ethernet.Ethernet
3. watch Memory be consumed.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
dpkt 1.7, Centos 5.5
Please provide any additional information below.
Attachments:
badpacket.pcap 142 bytes
packet appears fragmented, has bad checksum
File "./myscript.py", line 46, in <module>
eth = dpkt.ethernet.Ethernet(buf)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/ethernet.py", line 79,
in unpack
self._unpack_data(self.data)
File "/usr/local/lib/python2.6/site-packages/dpkt/ethernet.py", line 70,
in _unpack_data
self.data = self._typesw[self.type](buf)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/ip.py", line 60, in
unpack
self.data = self._protosw[self.p](buf)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/icmp.py", line 103, in
unpack
self.data = self._typesw[self.type](self.data)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/icmp.py", line 85, in
unpack
self.data = self.ip = ip.IP(self.data)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/ip.py", line 60, in
unpack
self.data = self._protosw[self.p](buf)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/gre.py", line 73, in
unpack
sre = self.SRE(self.data)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 72, in
__init__
self.unpack(args[0])
File "/usr/local/lib/python2.6/site-packages/dpkt/gre.py", line 45, in
unpack
dpkt.Packet.unpack(self, buf)
File "/usr/local/lib/python2.6/site-packages/dpkt/dpkt.py", line 127, in
unpack
struct.unpack(self.__hdr_fmt__, buf[:self.__hdr_len__])):
issue was fixed in August.
What was actually fixed? Python is an interpreted language, and until 2.5,
only grew in its memory usage (no free'ing of GC'd memory). Let me know if
we should close this out...
Go ahead and close it.
Without the fix, python would get stuck in an infinite loop where it would
repeatedly append self.SRE(self.data) to l, and this would cause python's
mem use to grow to fill all available memory, both physical and swap.
Memory leak was not the proper term.
diff with fix:
1c1
< # $Id: gre.py 30 2007-01-27 03:10:09Z dugsong $
---
> # $Id: gre.py 75 2010-08-03 14:42:19Z jon.oberheide $
73a74
> self.data = self.data[len(sre):]
78,79d78
< skip = sum(map(len, self.sre))
< self.data = self.data[skip:]
Issue still exists....
Python ver 2.6
Dpkt ver 1.7