【问题标题】:Access violation on calling j9port_startup_library调用 j9port_startup_library 时访问冲突
【发布时间】:2018-09-07 05:22:53
【问题描述】:

我已经使用这些说明为 Windows 构建了 openj9:https://github.com/eclipse/openj9/blob/master/buildenv/Build_Instructions_V8.md#windows

当我尝试以下代码时(Visual Studio 2017):

J9PortLibraryVersion portver;
J9PORT_SET_VERSION(&portver, J9PORT_CAPABILITY_MASK);

J9PortLibrary *portlib;
int32_t rc = j9port_allocate_library(&portver, &portlib);
if (rc != 0)
{
    printf("j9port_allocate_library failed with: %d\n", rc);
    return 1;
}

rc = j9port_create_library(portlib, &portver, sizeof(J9PortLibrary));
if (rc != 0)
{
    printf("j9port_create_library failed with %d\n", rc);
    return 1;
}

rc = j9port_startup_library(portlib);
if (rc != 0)
{
    printf("j9port_startup_library failed with %d\n", rc);
    return 1;
}
printf("j9port_startup_library: %d\n", rc);

我在 j9port_startup_library:Exception thrown at 0x00007FFF0FC9430A (j9thr29.dll) in sample.exe: 0xC0000005: Access violation reading location 0x0000000000000000. 上遇到访问冲突

检查 portlib 显示 portGlobals 是 NULL 我认为它不应该是。

当我在调试器之外运行 exe 时,我看到以下断言(由于某种原因我在调试器中看不到):

** 断言失败 ** j9prt.504 at common/j9port.c:404 Assert_PRT_true((omrthread_self() != ((void *)0)))

** 断言失败 ** omrport.0 at ../../omr/port/common/omrport.c:515 Assert_PRT_true((omrthread_self() != ((void *)0)))

我是否遗漏了一个步骤或导致此访问冲突的原因是什么?

编辑:我在 Windows 7 x64 上使用 Visual Studio 2010 重建项目,并在 VS2010 中的 MCE 上运行,VS 显示我们崩溃了

omrthread.c

static omrthread_monitor_t
monitor_allocate(omrthread_t self, intptr_t policy, intptr_t policyData)
{
   omrthread_monitor_t newMonitor;
   omrthread_library_t lib = self->library;

self 为 nil,因此抛出 ACCESS_VIOLATION: 截屏 .com/MMW59.png

【问题讨论】:

  • 什么是windows版本?是 Windows 10 吗?
  • 是的,我用 Visual Studio 2010 构建了 openj9,但我在 win10 和 Visual Studio 2017 中使用了头文件和库
  • 那么问题很可能是 Windows 中的数据执行保护 (DEP),如果是这种情况,请尝试将服务添加到系统属性 -> 高级选项卡 -> 数据执行保护或尝试禁用它以查看是否是导致问题的原因。告诉我进展如何。
  • 在项目设置中禁用 DEP + 通过 BCDEdit 全局禁用 DEP。同样的错误...
  • 有趣...您是否尝试在禁用后重新启动系统?

标签: java j9 openj9 omr


【解决方案1】:

这是在 Eclipse OpenJ9 github 项目中提出的:https://github.com/eclipse/openj9/issues/1564

答案是初始化端口库如下:

int main(int argc, char **argv) {
    omrthread_t attachedThread = NULL;
    J9PortLibraryVersion portver;
    J9PortLibrary portlib;
    intptr_t rc;
    intptr_t fd;

    rc = omrthread_init_library();
    if (rc != 0) {
        printf("omrthread_init_library failed with: %lld\n", rc);
        return 1;
    }

    rc = omrthread_attach_ex(&attachedThread, J9THREAD_ATTR_DEFAULT);
    if (rc != 0) {
        printf("omrthread_attach_ex failed with: %lld\n", rc);
        return 1;
    }

    J9PORT_SET_VERSION(&portver, J9PORT_CAPABILITY_MASK);
    rc = j9port_init_library(&portlib, &portver, sizeof(portlib));
    if (rc != 0) {
        printf("j9port_init_library failed with: %lld\n", rc);
        return 1;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2014-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多