JpCapWriter crashes JVM

时间秒杀一切 提交于 2019-12-13 21:56:43

问题


When I try to use JpCap Writer to save packets to a file, it causes JVM to crash.

Code:

captor=JpcapCaptor.openDevice(interfaceList[interfaceNumber], 65535, true, 20);
captor.setFilter("ip and tcp",true);


JpcapWriter writer=JpcapWriter.openDumpFile(captor,"write.txt");
for(int i=0;i<10;i++){
    Packet packet=captor.getPacket();
    writer.writePacket(packet);
  }
writer.close();

Crash info:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f283105953a, pid=3060, tid=139810797537024
#
# JRE version: 6.0_24-b24
# Java VM: OpenJDK 64-Bit Server VM (20.0-b12 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.11.4
# Distribution: Ubuntu 12.04 LTS, package 6b24-1.11.4-1ubuntu0.12.04.1
# Problematic frame:
# v  ~BufferBlob::jni_fast_GetLongField
#
# An error report file with more information is saved as:
# /root/workspace/Sniff/hs_err_pid3060.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Any idea how to solve it? Or any other alternative way to save packets in TCPDump format?


回答1:


I saw your comment on my question. I had this same problem and it was caused when I tried to close the writer after it had already been closed. You might be closing it unknowingly. Check your code, and also see what effect removing writer.close(); has for you.

If you don't need to manipulate the packets, I would recommend using Wireshark. It makes it very easy to capture packets as TCPDumps and add capture filters.



来源:https://stackoverflow.com/questions/13088612/jpcapwriter-crashes-jvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!