shadowbq/pcaprub — Issue #10: When accessing packet.data, memory errors occur
Author: jcarr
Created: 2011-12-02 05:07:08+00:00
State: open

When accessing packet.data inside of a each_packet loop a segfault occurs.

The code:

s=PCAPRUB::Pcap.open_offline(ARGV[0])

s.each_packet {|pkt|
a = Packet.parse(pkt.data)
}

Here's the segfault:

$ pcaptest.rb
pcaptest.rb:14: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0007 p:---- s:0026 b:0026 l:000025 d:000025 CFUNC :data
c:0006 p:0018 s:0023 b:0022 l:000468 d:000021 BLOCK pcaptest.rb:14
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :each_packet
c:0003 p:0119 s:0007 b:0007 l:000468 d:002630 EVAL pcaptest.rb:13
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000468 d:000468 TOP

-- Ruby level backtrace information ----------------------------------------
pcaptest.rb:13:in `

'
pcaptest.rb:13:in `each_packet'
pcaptest.rb:14:in `block in

'
pcaptest.rb:14:in `data'

-- C level backtrace information -------------------------------------------
/usr/lib/libruby.so.1.9(+0x158429) [0x7f4e9550b429]
/usr/lib/libruby.so.1.9(+0x59e89) [0x7f4e9540ce89]
/usr/lib/libruby.so.1.9(rb_bug+0xb7) [0x7f4e9540d8b7]
/usr/lib/libruby.so.1.9(+0xf8eff) [0x7f4e954abeff]
/lib/libc.so.6(+0x349e0) [0x7f4e950609e0]
/lib/libc.so.6(+0x84c5b) [0x7f4e950b0c5b]
/usr/lib/libruby.so.1.9(+0x1046b7) [0x7f4e954b76b7]
/usr/lib/libruby.so.1.9(+0x151451) [0x7f4e95504451]
/usr/lib/libruby.so.1.9(+0x1485fa) [0x7f4e954fb5fa]
/usr/lib/libruby.so.1.9(+0x14de3d) [0x7f4e95500e3d]
/usr/lib/libruby.so.1.9(rb_yield+0x256) [0x7f4e95506926]
/usr/lib/ruby/gems/1.9.1/gems/pcaprub-0.11.0/lib/pcaprub.so(+0x2076) [0x7f4e93b80076]
/usr/lib/libruby.so.1.9(+0x151451) [0x7f4e95504451]
/usr/lib/libruby.so.1.9(+0x1485fa) [0x7f4e954fb5fa]
/usr/lib/libruby.so.1.9(+0x14de3d) [0x7f4e95500e3d]
/usr/lib/libruby.so.1.9(rb_iseq_eval_main+0xaf) [0x7f4e95507fef]
/usr/lib/libruby.so.1.9(+0x5d8e2) [0x7f4e954108e2]
/usr/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7f4e954113cd]
/usr/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7f4e95412f7e]
ruby() [0x40080b]
/lib/libc.so.6(__libc_start_main+0xed) [0x7f4e9504d17d]
ruby() [0x400839]