来自JNI_CreateJavaVM(jvm.dll)的异常0xC0000005 [英] Exception 0xC0000005 from JNI_CreateJavaVM (jvm.dll)

查看:1361
本文介绍了来自JNI_CreateJavaVM(jvm.dll)的异常0xC0000005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下C ++代码初始化Java VM。 JNI_CreateJavaVM 抛出 0xC0000005 异常,但如果我忽略它就会成功。

I am initializing the Java VM using the following C++ code. JNI_CreateJavaVM throws a 0xC0000005 exception but succeeds none the less if I ignore it.


'Jni.exe'(Win32):已加载'C:\ Tools \ Java \ Jdk8.77x86 \ jre \\ \\bin\zip.dll。无法找到或打开PDB文件。

'Jni.exe' (Win32): Loaded 'C:\Tools\Java\Jdk8.77x86\jre\bin\zip.dll'. Cannot find or open the PDB file.

Jni.exe中0x02900282处抛出异常:0xC0000005:访问冲突读取位置0x00000000。

Exception thrown at 0x02900282 in Jni.exe: 0xC0000005: Access violation reading location 0x00000000.

'Jni.exe'(Win32):加载'C:\ Windows \SysWOW64 \ Shell32.dll'。无法找到或打开PDB文件。

'Jni.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.

我忘了设置或做某事或这是'正常'行为吗?

Am I forgetting to set or do something or is this 'normal' behaviour?

#include <array>
#include "jni.h"

int main( int argc, char const* args[])
{
    JavaVM* jvm;
    JNIEnv* env;

    std::array<JavaVMOption,1> options;
    options[0].optionString = "-Djava.class.path=C:/Users/Thomas/Documents/Visual Studio 2015/Projects/Jni/x64/Debug";
    options[0].extraInfo = nullptr;

    JavaVMInitArgs vm_args;
    vm_args.version = JNI_VERSION_1_8;
    vm_args.options = options.data();
    vm_args.nOptions = options.size();
    vm_args.ignoreUnrecognized = false;

    auto rc = JNI_CreateJavaVM( &jvm, reinterpret_cast<void**>(&env), &vm_args );
    if( rc == JNI_OK )
    {
        jvm->DestroyJavaVM();        
    }
}

发布和调试以及x86都会发生这种情况和x64版本。

This happens for both Release and Debug and for both x86 and x64 builds.

推荐答案

JVM主动使用OS信号(或Windows术语中的例外)用于其自身目的:

JVM actively uses OS signals (or exceptions in Windows terminology) for its own purposes:


  • 用于隐式空指针检查和堆栈溢出检查;

  • 用于安全点轮询;

  • 用于远程内存屏障;

  • 等。

  • for implicit null pointer checks and stack overflow checks;
  • for safepoint polling;
  • for remote memory barriers;
  • etc.

SEGV(或异常0xC0000005 )也是在JVM启动时有意生成的,以验证某些CPU / OS功能。某些操作系统或管理程序有一个错误,即AVX寄存器在信号处理后没有恢复。因此,JVM需要检查是否是这种情况(来源)。所以它通过写入零地址然后处理它来生成异常。

SEGV (or exception 0xC0000005) is also generated intentionally on JVM startup to verify certain CPU/OS features. Some OSes or hypervisors had a bug that AVX registers are not restored after signal processing. Therefore, JVM needs to check whether this is the case (the source). So it generates an exception by writing to zero address and then handles it.

这就是你的情况。是的,这很正常。

This is what happens in your case. And yes, it is normal.

这篇关于来自JNI_CreateJavaVM(jvm.dll)的异常0xC0000005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆