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.
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
.com/MMW59.png