Jpcap 破坏 JVM

发布于 2024-10-02 02:13:04 字数 8754 浏览 9 评论 0原文

我编写了以下程序,旨在将所有网络设备流量转储到文件中。我知道问题涉及 JpcapWriter 的使用。为什么我会收到如下所示的错误消息?

import jpcap.*;
import jpcap.packet.*;

public class dumptraffic
{
    private static final int maxPackets = 100;

    public static void main(String args[])
    {
        try
        {
            NetworkInterface[] devices = JpcapCaptor.getDeviceList();

            if (args.length != 1)
            {
                System.out.println("You must enter a device number.");

                int i = 0;
                for (NetworkInterface device : devices)
                    System.out.println((i++) + ": " + device.name);

                return;
            }

            JpcapCaptor jpcap = JpcapCaptor.openDevice(devices[Integer.parseInt(args[0].trim())], 2000, false, 20);
            JpcapWriter writer = JpcapWriter.openDumpFile(jpcap, "dump.pcap");

            for (int i = 0; i < maxPackets; i++)
                writer.writePacket(jpcap.getPacket());

            writer.close();

            System.out.println("Recorded packets to the file \"dump.pcap\"");
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

}

这是 Java 转储的日志:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0234659d, pid=4900, tid=5808
#
# JRE version: 6.0_22-b04
# Java VM: Java HotSpot(TM) Client VM (17.1-b03 mixed mode, sharing windows-x86 )
# Problematic frame:
# v  ~BufferBlob::jni_fast_GetLongField
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x02211c00):  JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x00000000, EBX=0x6da511e8, ECX=0x00000000, EDX=0x00000000
ESP=0x0033f578, EBP=0x0033f5b0, ESI=0x00000022, EDI=0x00000000
EIP=0x0234659d, EFLAGS=0x00010246

Top of Stack: (sp=0x0033f578)
0x0033f578:   02211d18 6d97567f 02211d18 00000000
0x0033f588:   00000022 00000000 02211d18 6da511e8
0x0033f598:   0033f58c 0033f19c 0033fd8c 6d9f4ed0
0x0033f5a8:   6da2a4b0 00000000 0033fc68 015d358c
0x0033f5b8:   02211d18 00000000 00000022 02211c00
0x0033f5c8:   380655e0 0033fc68 380655e0 0000005b
0x0033f5d8:   00000000 03000003 001521a8 77a94460
0x0033f5e8:   00000000 77a94460 00000000 001219b8 

Instructions: (pc=0x0234659d)
0x0234658d:   00 00 00 8b c1 83 e0 01 8b 54 04 0c 8b 74 24 10
0x0234659d:   8b 12 c1 ee 02 8b 04 32 8b 54 32 04 be e0 16 a6 


Stack: [0x002f0000,0x00340000],  sp=0x0033f578,  free space=13d0033f0ack
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~BufferBlob::jni_fast_GetLongField
C  [Jpcap.dll+0x358c]
j  dumptraffic.main([Ljava/lang/String;)V+127
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf3a9c]
V  [jvm.dll+0x186591]
V  [jvm.dll+0xf3b1d]
V  [jvm.dll+0xfd365]
V  [jvm.dll+0x104fbd]
C  [java.exe+0x2155]
C  [java.exe+0x85b4]
C  [kernel32.dll+0x4d0e9]
C  [ntdll.dll+0x419bb]
C  [ntdll.dll+0x4198e]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jpcap.JpcapWriter.writePacket(Ljpcap/packet/Packet;)V+0
j  dumptraffic.main([Ljava/lang/String;)V+127
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x02245800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2888, stack(0x04550000,0x045a0000)]
  0x0223e400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2620, stack(0x04500000,0x04550000)]
  0x0223d400 JavaThread "Attach Listener" daemon [_thread_blocked, id=4060, stack(0x044b0000,0x04500000)]
  0x0223a400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4280, stack(0x04460000,0x044b0000)]
  0x02232000 JavaThread "Finalizer" daemon [_thread_blocked, id=5952, stack(0x04410000,0x04460000)]
  0x02230c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=5860, stack(0x008c0000,0x00910000)]
=>0x02211c00 JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

Other Threads:
  0x0222f400 VMThread [stack: 0x003b0000,0x00400000] [id=4396]
  0x0224f400 WatcherThread [stack: 0x045a0000,0x045f0000] [id=4156]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 371K [0x28050000, 0x285a0000, 0x2d5a0000)
  eden space 4416K,   8% used [0x28050000, 0x280acf00, 0x284a0000)
  from space 512K,   0% used [0x284a0000, 0x284a0000, 0x28520000)
  to   space 512K,   0% used [0x28520000, 0x28520000, 0x285a0000)
 tenured generation   total 10944K, used 0K [0x2d5a0000, 0x2e050000, 0x38050000)
   the space 10944K,   0% used [0x2d5a0000, 0x2d5a0000, 0x2d5a0200, 0x2e050000)
 compacting perm gen  total 12288K, used 86K [0x38050000, 0x38c50000, 0x3c050000)
   the space 12288K,   0% used [0x38050000, 0x38065868, 0x38065a00, 0x38c50000)
    ro space 10240K,  51% used [0x3c050000, 0x3c57baf8, 0x3c57bc00, 0x3ca50000)
    rw space 12288K,  54% used [0x3ca50000, 0x3d0e76d8, 0x3d0e7800, 0x3d650000)

Dynamic libraries:
0x00400000 - 0x00424000     C:\Windows\system32\java.exe
0x779d0000 - 0x77af7000     C:\Windows\system32\ntdll.dll
0x77700000 - 0x777dc000     C:\Windows\system32\kernel32.dll
0x761c0000 - 0x76286000     C:\Windows\system32\ADVAPI32.dll
0x76460000 - 0x76523000     C:\Windows\system32\RPCRT4.dll
0x10000000 - 0x10048000     C:\Windows\system32\guard32.dll
0x76950000 - 0x769ed000     C:\Windows\system32\USER32.dll
0x77be0000 - 0x77c2b000     C:\Windows\system32\GDI32.dll
0x75f00000 - 0x75f08000     C:\Windows\system32\VERSION.dll
0x77500000 - 0x775aa000     C:\Windows\system32\msvcrt.dll
0x77b60000 - 0x77b7e000     C:\Windows\system32\IMM32.DLL
0x76880000 - 0x76948000     C:\Windows\system32\MSCTF.dll
0x77b10000 - 0x77b19000     C:\Windows\system32\LPK.DLL
0x76290000 - 0x7630d000     C:\Windows\system32\USP10.dll
0x75ef0000 - 0x75ef7000     C:\Windows\system32\fltlib.dll
0x7c340000 - 0x7c396000     C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da97000     C:\Program Files\Java\jre6\bin\client\jvm.dll
0x74900000 - 0x74932000     C:\Windows\system32\WINMM.dll
0x775b0000 - 0x776f5000     C:\Windows\system32\ole32.dll
0x763d0000 - 0x7645d000     C:\Windows\system32\OLEAUT32.dll
0x748c0000 - 0x748fd000     C:\Windows\system32\OLEACC.dll
0x75ec0000 - 0x75eec000     C:\Windows\system32\apphelp.dll
0x6d7a0000 - 0x6d7ac000     C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000     C:\Program Files\Java\jre6\bin\java.dll
0x6d280000 - 0x6d288000     C:\Program Files\Java\jre6\bin\hpi.dll
0x76070000 - 0x76077000     C:\Windows\system32\PSAPI.DLL
0x6d7e0000 - 0x6d7ef000     C:\Program Files\Java\jre6\bin\zip.dll
0x015d0000 - 0x015f8000     C:\Windows\System32\Jpcap.dll
0x763a0000 - 0x763cd000     C:\Windows\system32\WS2_32.dll
0x77b20000 - 0x77b26000     C:\Windows\system32\NSI.dll
0x045f0000 - 0x0463c000     C:\Windows\system32\wpcap.dll
0x00920000 - 0x00938000     C:\Windows\system32\packet.dll
0x75980000 - 0x75999000     C:\Windows\system32\iphlpapi.dll
0x75940000 - 0x75975000     C:\Windows\system32\dhcpcsvc.DLL
0x75e70000 - 0x75e9c000     C:\Windows\system32\DNSAPI.dll
0x75f10000 - 0x75f24000     C:\Windows\system32\Secur32.dll
0x75930000 - 0x75937000     C:\Windows\system32\WINNSI.DLL
0x75900000 - 0x75922000     C:\Windows\system32\dhcpcsvc6.DLL
0x6d600000 - 0x6d613000     C:\Program Files\Java\jre6\bin\net.dll
0x756f0000 - 0x7572b000     C:\Windows\system32\mswsock.dll
0x756e0000 - 0x756e5000     C:\Windows\System32\wship6.dll

VM Arguments:
java_command: dumptraffic 1
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Ruby192\bin;C:\Program Files\Java\jdk1.6.0_20\bin
USERNAME=Donald Taylor
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows Vista Build 6002 Service Pack 2

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 13, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2094396k(1168912k free), swap 4458364k(3080400k free)

vm_info: Java HotSpot(TM) Client VM (17.1-b03) for windows-x86 JRE (1.6.0_22-b04), built on Sep 15 2010 00:56:36 by "java_re" with MS VC++ 7.1 (VS2003)

time: Mon Nov 08 19:50:43 2010
elapsed time: 0 seconds

I have written the following program that is intended to dump all network device traffic to a file. I know the problem involves the use of JpcapWriter. Why am I getting the error message shown below?

import jpcap.*;
import jpcap.packet.*;

public class dumptraffic
{
    private static final int maxPackets = 100;

    public static void main(String args[])
    {
        try
        {
            NetworkInterface[] devices = JpcapCaptor.getDeviceList();

            if (args.length != 1)
            {
                System.out.println("You must enter a device number.");

                int i = 0;
                for (NetworkInterface device : devices)
                    System.out.println((i++) + ": " + device.name);

                return;
            }

            JpcapCaptor jpcap = JpcapCaptor.openDevice(devices[Integer.parseInt(args[0].trim())], 2000, false, 20);
            JpcapWriter writer = JpcapWriter.openDumpFile(jpcap, "dump.pcap");

            for (int i = 0; i < maxPackets; i++)
                writer.writePacket(jpcap.getPacket());

            writer.close();

            System.out.println("Recorded packets to the file \"dump.pcap\"");
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

}

Here is the log that Java dumps:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0234659d, pid=4900, tid=5808
#
# JRE version: 6.0_22-b04
# Java VM: Java HotSpot(TM) Client VM (17.1-b03 mixed mode, sharing windows-x86 )
# Problematic frame:
# v  ~BufferBlob::jni_fast_GetLongField
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x02211c00):  JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x00000000, EBX=0x6da511e8, ECX=0x00000000, EDX=0x00000000
ESP=0x0033f578, EBP=0x0033f5b0, ESI=0x00000022, EDI=0x00000000
EIP=0x0234659d, EFLAGS=0x00010246

Top of Stack: (sp=0x0033f578)
0x0033f578:   02211d18 6d97567f 02211d18 00000000
0x0033f588:   00000022 00000000 02211d18 6da511e8
0x0033f598:   0033f58c 0033f19c 0033fd8c 6d9f4ed0
0x0033f5a8:   6da2a4b0 00000000 0033fc68 015d358c
0x0033f5b8:   02211d18 00000000 00000022 02211c00
0x0033f5c8:   380655e0 0033fc68 380655e0 0000005b
0x0033f5d8:   00000000 03000003 001521a8 77a94460
0x0033f5e8:   00000000 77a94460 00000000 001219b8 

Instructions: (pc=0x0234659d)
0x0234658d:   00 00 00 8b c1 83 e0 01 8b 54 04 0c 8b 74 24 10
0x0234659d:   8b 12 c1 ee 02 8b 04 32 8b 54 32 04 be e0 16 a6 


Stack: [0x002f0000,0x00340000],  sp=0x0033f578,  free space=13d0033f0ack
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v  ~BufferBlob::jni_fast_GetLongField
C  [Jpcap.dll+0x358c]
j  dumptraffic.main([Ljava/lang/String;)V+127
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf3a9c]
V  [jvm.dll+0x186591]
V  [jvm.dll+0xf3b1d]
V  [jvm.dll+0xfd365]
V  [jvm.dll+0x104fbd]
C  [java.exe+0x2155]
C  [java.exe+0x85b4]
C  [kernel32.dll+0x4d0e9]
C  [ntdll.dll+0x419bb]
C  [ntdll.dll+0x4198e]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jpcap.JpcapWriter.writePacket(Ljpcap/packet/Packet;)V+0
j  dumptraffic.main([Ljava/lang/String;)V+127
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x02245800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2888, stack(0x04550000,0x045a0000)]
  0x0223e400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2620, stack(0x04500000,0x04550000)]
  0x0223d400 JavaThread "Attach Listener" daemon [_thread_blocked, id=4060, stack(0x044b0000,0x04500000)]
  0x0223a400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4280, stack(0x04460000,0x044b0000)]
  0x02232000 JavaThread "Finalizer" daemon [_thread_blocked, id=5952, stack(0x04410000,0x04460000)]
  0x02230c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=5860, stack(0x008c0000,0x00910000)]
=>0x02211c00 JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

Other Threads:
  0x0222f400 VMThread [stack: 0x003b0000,0x00400000] [id=4396]
  0x0224f400 WatcherThread [stack: 0x045a0000,0x045f0000] [id=4156]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 371K [0x28050000, 0x285a0000, 0x2d5a0000)
  eden space 4416K,   8% used [0x28050000, 0x280acf00, 0x284a0000)
  from space 512K,   0% used [0x284a0000, 0x284a0000, 0x28520000)
  to   space 512K,   0% used [0x28520000, 0x28520000, 0x285a0000)
 tenured generation   total 10944K, used 0K [0x2d5a0000, 0x2e050000, 0x38050000)
   the space 10944K,   0% used [0x2d5a0000, 0x2d5a0000, 0x2d5a0200, 0x2e050000)
 compacting perm gen  total 12288K, used 86K [0x38050000, 0x38c50000, 0x3c050000)
   the space 12288K,   0% used [0x38050000, 0x38065868, 0x38065a00, 0x38c50000)
    ro space 10240K,  51% used [0x3c050000, 0x3c57baf8, 0x3c57bc00, 0x3ca50000)
    rw space 12288K,  54% used [0x3ca50000, 0x3d0e76d8, 0x3d0e7800, 0x3d650000)

Dynamic libraries:
0x00400000 - 0x00424000     C:\Windows\system32\java.exe
0x779d0000 - 0x77af7000     C:\Windows\system32\ntdll.dll
0x77700000 - 0x777dc000     C:\Windows\system32\kernel32.dll
0x761c0000 - 0x76286000     C:\Windows\system32\ADVAPI32.dll
0x76460000 - 0x76523000     C:\Windows\system32\RPCRT4.dll
0x10000000 - 0x10048000     C:\Windows\system32\guard32.dll
0x76950000 - 0x769ed000     C:\Windows\system32\USER32.dll
0x77be0000 - 0x77c2b000     C:\Windows\system32\GDI32.dll
0x75f00000 - 0x75f08000     C:\Windows\system32\VERSION.dll
0x77500000 - 0x775aa000     C:\Windows\system32\msvcrt.dll
0x77b60000 - 0x77b7e000     C:\Windows\system32\IMM32.DLL
0x76880000 - 0x76948000     C:\Windows\system32\MSCTF.dll
0x77b10000 - 0x77b19000     C:\Windows\system32\LPK.DLL
0x76290000 - 0x7630d000     C:\Windows\system32\USP10.dll
0x75ef0000 - 0x75ef7000     C:\Windows\system32\fltlib.dll
0x7c340000 - 0x7c396000     C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da97000     C:\Program Files\Java\jre6\bin\client\jvm.dll
0x74900000 - 0x74932000     C:\Windows\system32\WINMM.dll
0x775b0000 - 0x776f5000     C:\Windows\system32\ole32.dll
0x763d0000 - 0x7645d000     C:\Windows\system32\OLEAUT32.dll
0x748c0000 - 0x748fd000     C:\Windows\system32\OLEACC.dll
0x75ec0000 - 0x75eec000     C:\Windows\system32\apphelp.dll
0x6d7a0000 - 0x6d7ac000     C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000     C:\Program Files\Java\jre6\bin\java.dll
0x6d280000 - 0x6d288000     C:\Program Files\Java\jre6\bin\hpi.dll
0x76070000 - 0x76077000     C:\Windows\system32\PSAPI.DLL
0x6d7e0000 - 0x6d7ef000     C:\Program Files\Java\jre6\bin\zip.dll
0x015d0000 - 0x015f8000     C:\Windows\System32\Jpcap.dll
0x763a0000 - 0x763cd000     C:\Windows\system32\WS2_32.dll
0x77b20000 - 0x77b26000     C:\Windows\system32\NSI.dll
0x045f0000 - 0x0463c000     C:\Windows\system32\wpcap.dll
0x00920000 - 0x00938000     C:\Windows\system32\packet.dll
0x75980000 - 0x75999000     C:\Windows\system32\iphlpapi.dll
0x75940000 - 0x75975000     C:\Windows\system32\dhcpcsvc.DLL
0x75e70000 - 0x75e9c000     C:\Windows\system32\DNSAPI.dll
0x75f10000 - 0x75f24000     C:\Windows\system32\Secur32.dll
0x75930000 - 0x75937000     C:\Windows\system32\WINNSI.DLL
0x75900000 - 0x75922000     C:\Windows\system32\dhcpcsvc6.DLL
0x6d600000 - 0x6d613000     C:\Program Files\Java\jre6\bin\net.dll
0x756f0000 - 0x7572b000     C:\Windows\system32\mswsock.dll
0x756e0000 - 0x756e5000     C:\Windows\System32\wship6.dll

VM Arguments:
java_command: dumptraffic 1
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Ruby192\bin;C:\Program Files\Java\jdk1.6.0_20\bin
USERNAME=Donald Taylor
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows Vista Build 6002 Service Pack 2

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 13, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2094396k(1168912k free), swap 4458364k(3080400k free)

vm_info: Java HotSpot(TM) Client VM (17.1-b03) for windows-x86 JRE (1.6.0_22-b04), built on Sep 15 2010 00:56:36 by "java_re" with MS VC++ 7.1 (VS2003)

time: Mon Nov 08 19:50:43 2010
elapsed time: 0 seconds

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

水晶透心 2024-10-09 02:13:04

我无法解决您的问题,但您可能会在 Google 网上论坛的 jpcap 讨论区上找到解决方案。

扫描消息(关键字“jvm crash”),我注意到其中一条消息说问题是调用了带有错误参数的方法。因此,您可以尝试仔细检查您的代码是否正确使用 API。

我不会向 Sun / Oracle 报告此事。故障转储中的证据表明某些东西使用 JNI 的方式存在错误。

I have no solution to your problem, but you might find one on the jpcap discussion board on Google Groups.

Scanning through the messages (keywords "jvm crash") I noted one saying that the problem turned out to be calling a method with the wrong parameters. So you might try double-checking that your code is using the API correctly.

I would not report this to Sun / Oracle. The evidence in the crash dump points to an error in the way that something is using JNI.

眼波传意 2024-10-09 02:13:04

您是否以 root 或 m$ 等效身份运行它?在网络接口上混杂收集数据包需要操作系统的一些额外权限。

Are you running it as root or m$ equivalent? Collecting packets on a network interface promiscuously requires some additional privileges from the OS.

万劫不复 2024-10-09 02:13:04

关键一行是:

# The crash happened outside the Java Virtual Machine in native code.

jpcap库使用本机代码,并且本机代码出现段错误。因此,这是 jpcap 库中的错误,而不是 JVM 中的错误。来自 Github 上的文档

Internally, jpcap implements bindings to the libpcap system library 
through JNI (the Java Native Interface).

现在,如果你愿意,你可以尝试调试通过在 GDB 中运行整个过程来解决段错误。

然而。注意到

jpcap utilizes libpcap, a widely deployed shared-library for capturing 
user-level packets. libpcap must be installed on your system in order 
to use jpcap.

文档中的内容,并考虑到段错误的常见原因是缺少共享库,我怀疑您的系统上没有安装 pcap 库。

The key line is:

# The crash happened outside the Java Virtual Machine in native code.

That is, the jpcap library uses native code, and the native code segfaulted. This is therefore a bug in the jpcap library, not in the JVM. From the documentation on Github:

Internally, jpcap implements bindings to the libpcap system library 
through JNI (the Java Native Interface).

Now, if you want, you could try to debug the segfault by running the whole thing in GDB.

However. Noting

jpcap utilizes libpcap, a widely deployed shared-library for capturing 
user-level packets. libpcap must be installed on your system in order 
to use jpcap.

in the docs, and considering the fact that a common cause of segfaults is a missing shared library, I suspect that you don't have the pcap library installed on your system.

云醉月微眠 2024-10-09 02:13:04

在 for 循环中使用此语句

  if(captor.getPacket()==null || captor.getPacket()==Packet.EOF) break;

use this statement inside your for loop

  if(captor.getPacket()==null || captor.getPacket()==Packet.EOF) break;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文