JVM crash while modifying Pcap Packet with SCTP payload

1 reply [Last post]
karthiknvenkat
Offline
Joined: 08/22/2016

I am new to jnetPcap, I am trying to build simple application that reads from a pcap file that has SCTP payload and modifies some of the attributes in the SCTP payload data and writes the modified pcap packet to another file. The following JVM crash is reported in the console while running my app after processing 31 pcakets:

jNetPCAP API version: 1.4.r1425
OS: Open Suse 13.2, kernel version: 3.16.7-35-desktop #1 SMP PREEMPT Sun Feb 7 17:32:21 UTC 2016 (832c776) x86_64 x86_64 x86_64 GNU/Linux

CRASH INFO:
-------------
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f06558ca125, pid=3373, tid=139665193740032
#
# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libc.so.6+0x78125]2016-08-22 07:13:24

THREAD DUMP:
-------------
I also did a kill -3 on the pid, here's the thread dump info:
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode):

"DisposableGC" daemon prio=10 tid=0x00007f065011f800 nid=0xd3f in Object.wait() [0x00007f061fddc000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d7181608> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
- locked <0x00000007d7181608> (a java.lang.ref.ReferenceQueue$Lock)
at org.jnetpcap.nio.DisposableGC.drainRefQueueLoop(Unknown Source)
at org.jnetpcap.nio.DisposableGC$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)

"Service Thread" daemon prio=10 tid=0x00007f065009f800 nid=0xd3d runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=10 tid=0x00007f065009d800 nid=0xd3c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=10 tid=0x00007f065009a800 nid=0xd3b waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x00007f0650098000 nid=0xd3a waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x00007f0650076800 nid=0xd39 in Object.wait() [0x00007f0649a03000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d7004858> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
- locked <0x00000007d7004858> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" daemon prio=10 tid=0x00007f0650074800 nid=0xd38 in Object.wait() [0x00007f0649b04000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007d7004470> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
- locked <0x00000007d7004470> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x00007f0650007800 nid=0xd2e runnable [0x00007f0656428000]
java.lang.Thread.State: RUNNABLE
at org.jnetpcap.nio.JMemory.allocate0(Native Method)
- locked <0x00000007d7083e50> (a java.lang.Class for org.jnetpcap.nio.JMemory)
at org.jnetpcap.nio.JMemory.allocate(Unknown Source)
at org.jnetpcap.Pcap.loop(Native Method)
at org.jnetpcap.Pcap.loop(Unknown Source)
at nn.test.tools.pcapprocessor.PCAPDumperTest.main(PCAPDumperTest.java:54)

"VM Thread" prio=10 tid=0x00007f0650070000 nid=0xd37 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x00007f065001d800 nid=0xd2f runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x00007f065001f800 nid=0xd30 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x00007f0650021000 nid=0xd31 runnable

"GC task thread#3 (ParallelGC)" prio=10 tid=0x00007f0650023000 nid=0xd32 runnable

"GC task thread#4 (ParallelGC)" prio=10 tid=0x00007f0650025000 nid=0xd33 runnable

"GC task thread#5 (ParallelGC)" prio=10 tid=0x00007f0650026800 nid=0xd34 runnable

"GC task thread#6 (ParallelGC)" prio=10 tid=0x00007f0650028800 nid=0xd35 runnable

"GC task thread#7 (ParallelGC)" prio=10 tid=0x00007f065002a800 nid=0xd36 runnable

"VM Periodic Task Thread" prio=10 tid=0x00007f06500aa800 nid=0xd3e waiting on condition

JNI global references: 313

Heap
PSYoungGen total 36864K, used 15251K [0x00000007d7000000, 0x00000007d9900000, 0x0000000800000000)
eden space 31744K, 48% used [0x00000007d7000000,0x00000007d7ee4e80,0x00000007d8f00000)
from space 5120K, 0% used [0x00000007d9400000,0x00000007d9400000,0x00000007d9900000)
to space 5120K, 0% used [0x00000007d8f00000,0x00000007d8f00000,0x00000007d9400000)
ParOldGen total 83968K, used 0K [0x0000000785000000, 0x000000078a200000, 0x00000007d7000000)
object space 83968K, 0% used [0x0000000785000000,0x0000000785000000,0x000000078a200000)
PSPermGen total 21504K, used 5243K [0x000000077fe00000, 0x0000000781300000, 0x0000000785000000)
object space 21504K, 24% used [0x000000077fe00000,0x000000078031ec98,0x0000000781300000)

^CAborted

Application code sinippet:(Code that modifies the actual data has been removed, this code simply resets the pcap packet by transfer data from the original pcap packet bytes, the same problem exists:

Main code:
-----------
pcap = Pcap.openOffline(pcapFile, errbuf);
if (pcap == null) {
System.err.println(errbuf); // Error is stored in errbuf if any
return;
}

dumper = pcap.dumpOpen(outputFile); // output file
if (dumper == null) {
System.err.println("Dumper = null, exiting");
System.exit(1);
}
pcap.loop(Pcap.LOOP_INFINITE, new PacketHandlerImpl(), dumper);

PcapPacketHandlerImpl nextPacket(PcapPacket packet, PcapDumper dumper) code snippet:
-------------------------------------------------------------------------------------

Buffer jbuf = new JBuffer(packet.getTotalSize());
packet.transferTo(jbuf);
byte[] packetBytes = jbuf.getByteArray(0, jbuf.size());

packet.transferFrom(packetBytes);

If the line "packet.transferFrom(packetBytes)" is commented out, I have no issues.

Any help would be greatly appreciated, I am stuck with this problem for this project and we need to determine soon if this project can be done using jnetPcap. Thank you so much for your time in advance.

Regards,
Karthik

Mark Bednarczyk
Offline
Joined: 03/22/2008
Does the problem occur right

Does the problem occur right away or some time after the application has been running for some time?

Sly Technologies, Inc.
http://slytechs.com

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.