VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1301|回复: 6

Java抓取数据包出错

[复制链接]

2

主题

5

帖子

5.00

积分

新手上路

Rank: 1

积分
5.00
发表于 2020-9-28 15:30:01 | 显示全部楼层 |阅读模式
import jpcap.Jpcap;
import jpcap.JpcapHandler;
import jpcap.Packet;

public class JpcapTip implements JpcapHandler {

        public void handlePacket(Packet packet) {
                System.out.println(packet);
        }

        public static void main(String[] args) throws java.io.IOException {
                String[] devices = Jpcap.getDeviceList();

                // for (int i = 0; i < devices.length; i++) {
                // System.out.println(devices[i]);
                // }

                String deviceName = devices[0];
                Jpcap jpcap = Jpcap.openDevice(deviceName, 1024, false, 1);
                jpcap.processPacket(-1, new JpcapTip());

                Packet packet = jpcap.getPacket();

                System.out.println(packet.toString());

        }
}


为什么在jpcap.getPacket();出现下述奇怪的错误呢?
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x10001529, pid=756, tid=3128
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_08-b03 mixed mode, sharing)
# Problematic frame:
# C  [Jpcap.dll+0x1529]
#
# An error report file with more information is saved as hs_err_pid756.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
回复

使用道具 举报

0

主题

39

帖子

23.00

积分

新手上路

Rank: 1

积分
23.00
发表于 2020-9-29 09:00:02 | 显示全部楼层
1.5.0_08-b03,升级一下JDK吧,或者把hs_err_pid756.log的内容精简上来看看。
回复

使用道具 举报

1

主题

51

帖子

32.00

积分

新手上路

Rank: 1

积分
32.00
发表于 2020-9-29 11:45:01 | 显示全部楼层
# An unexpected error has been detected by HotSpot Virtual Machine:
JDK的问题,是跑一次就报一次错,还是偶尔发生的~
回复

使用道具 举报

2

主题

5

帖子

5.00

积分

新手上路

Rank: 1

积分
5.00
 楼主| 发表于 2020-9-30 16:15:01 | 显示全部楼层
谢谢各位兄弟,我的jdk是1.5.0_08的,应该不是jdk的问题。我的JPcap用的是在Sourceforge.net里下载的jpcap1.4,有点老,不知道是不是这个问题?
回复

使用道具 举报

2

主题

5

帖子

5.00

积分

新手上路

Rank: 1

积分
5.00
 楼主| 发表于 2020-9-30 16:30:02 | 显示全部楼层
hs_err_pid756.log的内容是这样的:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x10001529, pid=4084, tid=3644
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_08-b03 mixed mode, sharing)
# Problematic frame:
# C  [Jpcap.dll+0x1529]
#

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

Current thread (0x00823ab0):  JavaThread "main" [_thread_in_native, id=3644]

siginfo: ExceptionCode=0xc0000005, reading address 0x0000000c

Registers:
EAX=0x00000001, EBX=0x26c26b78, ECX=0x0000000c, EDX=0x00000000
ESP=0x0006fa04, EBP=0x1000e2a0, ESI=0x00823b70, EDI=0x00000000
EIP=0x10001529, EFLAGS=0x00010246

Top of Stack: (sp=0x0006fa04)
0x0006fa04:   00823b70 00000000 0006fa7c 26c26b78
0x0006fa14:   00000001 02da8580 10001fde 00000000
0x0006fa24:   0006fa7c 00bd8215 00823ab0 00000000
0x0006fa34:   0006fa5c 00000000 00823ab0 26c26b78
0x0006fa44:   00000000 0006fa7c 00bd8215 00823ab0
0x0006fa54:   00bd832f 00823b70 0006fa8c 0006fa60
0x0006fa64:   26c26b78 0006fa8c 26c27090 00000000
0x0006fa74:   26c26b78 0006fa8c 0006faac 00bd2aba

Instructions: (pc=0x10001529)
0x10001519:   45 00 8b 0c 85 60 a1 00 10 57 8b 7c 24 2c 33 d2
0x10001529:   66 8b 14 39 89 7c 24 10 89 6c 24 34 52 ff 15 f0


Stack: [0x00030000,0x00070000),  sp=0x0006fa04,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [Jpcap.dll+0x1529]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jpcap.Jpcap.getPacket()Ljpcap/Packet;+0
j  subjectprogram.JpcapTip.main([Ljava/lang/String;)V+19
v  ~StubRoutines::call_stub

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

Java Threads: ( => current thread )
  0x00830510 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=984]
  0x0082f860 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1268]
  0x0082e670 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=820]
  0x0082dbe0 JavaThread "Finalizer" daemon [_thread_blocked, id=3172]
  0x0082c9a0 JavaThread "Reference Handler" daemon [_thread_blocked, id=1640]
=>0x00823ab0 JavaThread "main" [_thread_in_native, id=3644]

Other Threads:
  0x0082bbc0 VMThread [id=3868]
  0x008310c0 WatcherThread [id=1136]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation   total 576K, used 373K [0x22bd0000, 0x22c70000, 0x230b0000)
  eden space 512K,  72% used [0x22bd0000, 0x22c2d4a8, 0x22c50000)
  from space 64K,   0% used [0x22c50000, 0x22c50000, 0x22c60000)
  to   space 64K,   0% used [0x22c60000, 0x22c60000, 0x22c70000)
tenured generation   total 1408K, used 0K [0x230b0000, 0x23210000, 0x26bd0000)
   the space 1408K,   0% used [0x230b0000, 0x230b0000, 0x230b0200, 0x23210000)
compacting perm gen  total 8192K, used 375K [0x26bd0000, 0x273d0000, 0x2abd0000)
   the space 8192K,   4% used [0x26bd0000, 0x26c2de68, 0x26c2e000, 0x273d0000)
    ro space 8192K,  63% used [0x2abd0000, 0x2b0dd608, 0x2b0dd800, 0x2b3d0000)
    rw space 12288K,  46% used [0x2b3d0000, 0x2b970608, 0x2b970800, 0x2bfd0000)

Dynamic libraries:
0x00400000 - 0x0040d000         C:\Program Files\Java\jre1.5.0_08\bin\javaw.exe
0x7c920000 - 0x7c9b4000         C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c91c000         C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e49000         C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee1000         C:\WINDOWS\system32\RPCRT4.dll
0x77d10000 - 0x77d9f000         C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f37000         C:\WINDOWS\system32\GDI32.dll
0x77be0000 - 0x77c38000         C:\WINDOWS\system32\MSVCRT.dll
0x76300000 - 0x7631d000         C:\WINDOWS\system32\IMM32.DLL
0x62c20000 - 0x62c29000         C:\WINDOWS\system32\LPK.DLL
0x73fa0000 - 0x7400b000         C:\WINDOWS\system32\USP10.dll
0x6d6c0000 - 0x6d85b000         C:\Program Files\Java\jre1.5.0_08\bin\client\jvm.dll
0x76b10000 - 0x76b3a000         C:\WINDOWS\system32\WINMM.dll
0x6d280000 - 0x6d288000         C:\Program Files\Java\jre1.5.0_08\bin\hpi.dll
0x76bc0000 - 0x76bcb000         C:\WINDOWS\system32\PSAPI.DLL
0x6d690000 - 0x6d69c000         C:\Program Files\Java\jre1.5.0_08\bin\verify.dll
0x6d300000 - 0x6d31d000         C:\Program Files\Java\jre1.5.0_08\bin\java.dll
0x6d6b0000 - 0x6d6bf000         C:\Program Files\Java\jre1.5.0_08\bin\zip.dll
0x10000000 - 0x10012000         C:\Program Files\Java\jre1.5.0_08\bin\Jpcap.dll
0x71a20000 - 0x71a37000         C:\WINDOWS\system32\WS2_32.dll
0x71a10000 - 0x71a18000         C:\WINDOWS\system32\WS2HELP.dll
0x02da0000 - 0x02de1000         C:\WINDOWS\system32\wpcap.dll
0x02df0000 - 0x02e05000         C:\WINDOWS\system32\packet.dll
0x02e10000 - 0x02e20000         C:\WINDOWS\system32\WanPacket.dll
0x5a740000 - 0x5a751000         C:\WINDOWS\system32\NPPTools.dll
0x727a0000 - 0x7289e000         C:\WINDOWS\system32\MFC42u.DLL
0x76990000 - 0x76acd000         C:\WINDOWS\system32\ole32.dll
0x770f0000 - 0x7717c000         C:\WINDOWS\system32\OLEAUT32.dll
0x76d30000 - 0x76d48000         C:\WINDOWS\system32\iphlpapi.dll
0x77bd0000 - 0x77bd8000         C:\WINDOWS\system32\VERSION.dll
0x61be0000 - 0x61bed000         C:\WINDOWS\system32\MFC42LOC.DLL
0x610c0000 - 0x610d1000         C:\WINDOWS\system32\npp\ndisnpp.dll
0x5adc0000 - 0x5adf7000         C:\WINDOWS\system32\uxtheme.dll
0x74680000 - 0x746cb000         C:\WINDOWS\system32\MSCTF.dll
0x76fa0000 - 0x7701f000         C:\WINDOWS\system32\CLBCATQ.DLL
0x77020000 - 0x770ba000         C:\WINDOWS\system32\COMRes.dll
0x77fc0000 - 0x77fd1000         C:\WINDOWS\system32\Secur32.dll

VM Arguments:
java_command: subjectprogram.JpcapTip
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_08
CLASSPATH=.;C:\Program Files\Java\jdk1.5.0_08\lib\tools.jar;C:\Program Files\Java\jdk1.5.0_08\lib\dt.jar;
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Java\jdk1.5.0_08\bin;D:\Program Files\Rational\common;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files\backburner 2\
USERNAME=夏志雄
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 8 Stepping 1, AuthenticAMD



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

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 (cores per cpu 1, threads per core 1) family 6 model 8 stepping 1, cmov, cx8, fxsr, mmx, sse, mmxext, 3dnowext, 3dnow

Memory: 4k page, physical 523760k(103052k free), swap 1279916k(831972k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_08-b03) for windows-x86, built on Jul 26 2016 01:10:50 by "java_re" with MS VC++ 6.0

回复

使用道具 举报

0

主题

39

帖子

23.00

积分

新手上路

Rank: 1

积分
23.00
发表于 2020-9-30 18:30:02 | 显示全部楼层
汗,没弄过Jpcap
换个操作系统与JDK再试试吧。
回复

使用道具 举报

0

主题

3

帖子

4.00

积分

新手上路

Rank: 1

积分
4.00
发表于 2020-10-1 10:15:01 | 显示全部楼层
哦 顺便说一句   现在Jpcap好像有两个版本,http://jpcap.sourceforge.net/上面写

Jpcap development is hosted at http://www.sf.net/projects/jpcap,我把jpcap-0.5.1下载下来以后,发现里面的F&Q里面有一句话:

Q: Is this Jpcap related to the Jpcap on sourceforge?

A:  No. They are independently developed, and thus are totally different products.


靠   妈的  我真是糊涂了~~~~~~~~`
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表