2

I have build openj9 for Windows using these instructions: https://github.com/eclipse/openj9/blob/master/buildenv/Build_Instructions_V8.md#windows

When I try the following code (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);

I get an Access Violation on j9port_startup_library: Exception thrown at 0x00007FFF0FC9430A (j9thr29.dll) in sample.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Inspecting portlib shows that portGlobals is NULL which I don't think it should be. portlib

When I run the exe outside of the debugger I see the following asserts (which I don't see in the debugger for some reason):

** ASSERTION FAILED ** j9prt.504 at common/j9port.c:404 Assert_PRT_true((omrthread_self() != ((void *)0)))

** ASSERTION FAILED ** omrport.0 at ../../omr/port/common/omrport.c:515 Assert_PRT_true((omrthread_self() != ((void *)0)))

Am I missing a step or what is causing this Access Violation?

EDIT: I rebuild the project on Windows 7 x64 with Visual Studio 2010 and ran above MCE in VS2010, VS shows me that we crash in

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 is nil and therefore an ACCESS_VIOLATION is thrown: screenshot enter image description here.com/MMW59.png

Remko
  • 7,214
  • 2
  • 32
  • 52
  • What's the windows version? is it windows 10? – Vikram Palakurthi Mar 28 '18 at 14:48
  • Yes, I built the openj9 with visual studio 2010 but I use the headers and libs with win10 and visual studio 2017 – Remko Mar 28 '18 at 16:22
  • Then the problem be most likely be with Data Execution Prevention (DEP) in windows, if that's the case try add the service to the DEP list in System Properties -> Advanced Tab -> Data Execution Prevention or try disabling it ones to see if that's what causing the trouble. Let me know how it goes. – Vikram Palakurthi Mar 28 '18 at 16:28
  • Disabled DEP in the project settings + disabled DEP globally via BCDEdit. Same error... – Remko Mar 28 '18 at 20:58
  • Interesting... did you try restarting the system after the disable? – Vikram Palakurthi Mar 28 '18 at 20:59
  • yes I did....... – Remko Mar 28 '18 at 21:18
  • Sorry that it did not work, although I am sure you could have found this link but I would still provide just in case if you did not find it. https://windowsreport.com/exception-access-violation-windows-10/ provides multiple workarounds to fix this issues. Solution 9 – Reinstall the application and Solution 7 – Use the Compatibility mode, Solution 3 – Disable User Account Control (not recommended) but give it a try to find if that's the cause. And I see you have already created an issues in github https://github.com/eclipse/openj9/issues/1564. – Vikram Palakurthi Mar 29 '18 at 01:22
  • See my edit, this doesn't look like an os or environment issue – Remko Mar 31 '18 at 21:24

1 Answers1

-1

This was asked at the Eclipse OpenJ9 github project: https://github.com/eclipse/openj9/issues/1564

The answer there was to init the port library as follows:

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;
    }
Dan Heidinga
  • 489
  • 2
  • 11