eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.29k stars 722 forks source link

JTReg test fail - Linux & Windows : java/net/Socket/asyncClose/AsyncClose.java #4560

Open ben-walsh opened 5 years ago

ben-walsh commented 5 years ago

Intermittent failure(s) ...

STDOUT:
******************************
Test: Socket.getInputStream().read()
Failed: Socket.getInputStream().read() wasn't preempted

******************************
Test: Socket.getInputStream().read() (with timeout)
Failed: Socket.getInputStream().read() wasn't preempted

******************************
Test: Socket.getOutputStream().write()
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket)
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket) (timeout specified)
Passed.

******************************
Test: ServerSocket.accept()
Passed.

******************************
Test: ServerSocket.accept() (with timeout)
Passed.

STDERR:
java.lang.Exception: 2 sub-tests failed - see log.
    at AsyncClose.main(AsyncClose.java:73)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
    at java.base/java.lang.Thread.run(Thread.java:825)
STDOUT:
******************************
Test: Socket.getInputStream().read()
Passed.

******************************
Test: Socket.getInputStream().read() (with timeout)
Failed: Socket.getInputStream().read() wasn't preempted

******************************
Test: Socket.getOutputStream().write()
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket)
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket) (timeout specified)
Passed.

******************************
Test: ServerSocket.accept()
Passed.

******************************
Test: ServerSocket.accept() (with timeout)
Passed.

STDERR:
java.lang.Exception: 1 sub-tests failed - see log.
    at AsyncClose.main(AsyncClose.java:73)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
    at java.base/java.lang.Thread.run(Thread.java:825)

... of test https://github.com/ibmruntimes/openj9-openjdk-jdk11/blob/openj9/test/jdk/java/net/Socket/asyncClose/AsyncClose.java observed on both Linux and Windows ...

https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk11_j9_openjdktest_x86-64_linux/266/testReport/junit/java_net_Socket_asyncClose_AsyncClose/java/AsyncClose https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk11_j9_openjdktest_x86-64_windows/122/testReport/junit/java_net_Socket_asyncClose_AsyncClose/java/AsyncClose

I have kicked off a 100x (https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/946) and 100x with -Xint (https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/947) on Linux.

I have also kicked off a 100x with -Xint (https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/949) on Windows.

ben-walsh commented 5 years ago

https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/946 - showed a 17% failure rate.

https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/947 - showed a 34% failure rate.

https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/949 - showed a 8% failure rate.

JasonFengJ9 commented 5 years ago

@ben-walsh does RI pass this test without failures?

ben-walsh commented 5 years ago

@JasonFengJ9 This oldest available test run against Hotspot - https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk11_hs_openjdktest_x86-64_linux/150/testReport/java_net_Socket_asyncClose_AsyncClose/java/AsyncClose passes without such problems, as does each of the subsequent runs.

ben-walsh commented 5 years ago

@JasonFengJ9 As that could be luck given the lowish failure rates observed against OpenJ9, to raise confidence, I have kicked off a 100x run against Hotspot latest nightly - https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/963

ben-walsh commented 5 years ago

https://ci.adoptopenjdk.net/view/Test_grinder/job/Grinder/963 shows a 100/100 pass rate, so we can be confident that Hotspot does not have this problem. @JasonFengJ9

ChengJin01 commented 5 years ago

The problem can be reproduced locally with JIT on/off as follows:

 ../jdk_11.0.2_8_openj9/bin/java -Xint  AsyncClose
******************************
Test: Socket.getInputStream().read()
Failed: Socket.getInputStream().read() wasn't preempted

******************************
Test: Socket.getInputStream().read() (with timeout)
Failed: Socket.getInputStream().read() wasn't preempted

******************************
Test: Socket.getOutputStream().write()
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket)
Passed.

******************************
Test: DatagramSocket.receive(DatagramPacket) (timeout specified)
Passed.

******************************
Test: ServerSocket.accept()
Passed.

******************************
Test: ServerSocket.accept() (with timeout)
Passed.

Exception in thread "main" java.lang.Exception: 2 sub-tests failed - see log.
        at AsyncClose.main(AsyncClose.java:73)

Need to figure out how this test works and how it is related to VM.

ChengJin01 commented 5 years ago

Looking at the test code:

test/jdk/java/net/Socket/asyncClose/Socket_getInputStream_read.java
    public void run() {
        try {
            InputStream in = s.getInputStream();
            if (timeout > 0) {
                s.setSoTimeout(timeout);
            }
            latch.countDown();
            int n = in.read();
            failed("Socket.getInputStream().read() returned unexpectly!!");
        } catch (SocketException se) {
            se.printStackTrace();
            if (latch.getCount() != 1) {
                closed(); <--------------------- set to true if SocketException is catpure when calling in.read()
            }
        }

      public AsyncCloseTest go() {
        try {
            ServerSocket ss = new ServerSocket(0);
            InetAddress lh = InetAddress.getLocalHost();
            s.connect( new InetSocketAddress(lh, ss.getLocalPort()) );
            Socket s2 = ss.accept();
            Thread thr = new Thread(this);
            thr.start();
            latch.await();
            Thread.sleep(5000); //sleep, so Socket.getInputStream().read() can block
            s.close();
            thr.join();

            if (isClosed()) {  <------------- passed if closed
                return passed();
            } else {
                return failed("Socket.getInputStream().read() wasn't preempted");
            }

The expected result is to throw out SocketException as Socket.getInputStream().read() gets blocked

NET_Read: ret = -1, errno = 9 (from Java_java_net_SocketInputStream_socketRead0 at /openj9-openjdk-jdk11/src/java.base/unix/native/libnet/SocketInputStream.c)
java.net.SocketException: Socket closed
        at java.base/java.net.SocketInputStream.socketRead0(Native Method)
        at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
        at java.base/java.net.SocketInputStream.read(SocketInputStream.java:172)
        at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
        at java.base/java.net.SocketInputStream.read(SocketInputStream.java:208)
        at Socket_getInputStream_read.run(Socket_getInputStream_read.java:62)
        at java.base/java.lang.Thread.run(Thread.java:825)
******************************
Test: Socket.getInputStream().read()
Passed.

However, the test failed because Socket.getInputStream().read() still kept working till reached the end of inputstream during Thread.sleep(5000), which means sometimes Thread.sleep() didn't work correctly to block the read operation.

NET_Read: ret = 0, errno = 0
******************************
Test: Socket.getInputStream().read()
Failed: Socket.getInputStream().read() wasn't preempted

@babsingh

babsingh commented 5 years ago

@ChengJin01 1) did you verify using a micro-test that Thread.sleep() malfunctions? 2) did you verify that in.read() blocks before s.close() is invoked? 3) does s.close() consistently generate a SocketException for the blocked in.read()? 4) closed() is only invoked if latch.getCount() returns 0. did you verify that the CountDownLatch works properly: getCount(), countDown() and await()?

ChengJin01 commented 5 years ago

@babsingh

  1. The interesting thing I found is: [1] in the passed test, Thread.sleep() happened before NET_Read (in.read()) [2] in the failing test, NET_Read (in.read()) already finished before calling Thread.sleep(), which means there is no way to block it in such case.

  2. in passed case, s.close() should be invoked first when in.read() is blocked

  3. SocketException is generated by in.read() due to the closed socket

  4. there is no problem with these methods as OpenJDK11/Hotspot works good (tried many times).

babsingh commented 5 years ago

@ChengJin01

in the passed test, Thread.sleep() happened before NET_Read (in.read())

there is going to be a race condition between Thread.sleep() and in.read() since they are going to be invoked simultaneously. sleeping for 5 seconds should be sufficient in order to invoke in.read() before s.close().

in the failing test, NET_Read (in.read()) already finished before calling Thread.sleep()

in.read() should always block since no input data is available. So, in.read() shouldn't finish before Thread.sleep(). it should block until s.close() is invoked.

if in.read() finishes (doesn't block and returns) before calling thread.sleep(), then the issue is in the implementation of in.read().

More specific details are needed in order to pin-point the cause. Can you print timestamps around Thread.sleep() to verify its functionality? Also, print a timestamp before in.read() is invoked; this will tell us if in.read() is executed before s.close()?

import java.sql.Timestamp;
...
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(timestamp);
Thread.sleep(5000); //sleep, so Socket.getInputStream().read() can block
timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(timestamp);
s.close();

Documentation for InputStream.read: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/InputStream.html#read() This method blocks until input data is available.

Documentation for Socket.close: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/Socket.html#close() Any thread currently blocked in an I/O operation upon this socket will throw a SocketException.

Full test source code: https://github.com/ibmruntimes/openj9-openjdk-jdk11/blob/openj9/test/jdk/java/net/Socket/asyncClose/Socket_getInputStream_read.java

ChengJin01 commented 5 years ago

@babsingh ,

The race condition might exist but I doubt they should share the same lock with Thread.sleep() as follows:

/openj9-openjdk-jdk11/src/java.base/linux/native/libnet/linux_close.c

#define BLOCKING_IO_RETURN_INT(FD, FUNC) {      \
    int ret;                                    \
    threadEntry_t self;                         \
    fdEntry_t *fdEntry = getFdEntry(FD);        \
    if (fdEntry == NULL) {                      \
        errno = EBADF;                          \
        return -1;                              \
    }                                           \
    do {                                        \
        startOp(fdEntry, &self);                \ <------
        ret = FUNC;                             \
        endOp(fdEntry, &self);                  \
    } while (ret == -1 && errno == EINTR);      \
    return ret;                                 \
}

int NET_Read(int s, void* buf, size_t len) {
    BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
...

static inline void startOp(fdEntry_t *fdEntry, threadEntry_t *self)
{
    self->thr = pthread_self();
    self->intr = 0;

    pthread_mutex_lock(&(fdEntry->lock)); <-------
    {
        self->next = fdEntry->threads;
        fdEntry->threads = self;
    }
    pthread_mutex_unlock(&(fdEntry->lock));

In addition, I already confirmed in.read() was executed before Thread.sleep() and s.close() according the printing messages.

babsingh commented 5 years ago

What is the test doing?

While reading a SocketInputStream, in.read() should block since no input data is available.

/* Thread 1 */
try {
   private final Socket s = new Socket();
   InputStream in = s.getInputStream();
   int n = in.read();
} catch (SocketException se) {
   /* PASS */

While Thread 1 is blocked by in.read(), Thread 2 closes the socket s.close(), which should generate SocketException in Thread 1 in.read(). The test passes when Thread 1 successfully catches SocketException.

/* Thread 2 */
s.close();

Why is the test failing?

SocketInputStream in.read() doesn't block, and Thread 1 terminates before the socket is closed in Thread 2. When the socket is closed in Thread 2, SocketException isn't generated in Thread 1 in.read(), which causes the test to fail.

Where SocketInputStream in.read() blocks in native code?

In /openj9-openjdk-jdk11/src/java.base/linux/native/libnet/linux_close.c, while executing FUNC == recv.

recv man page: http://man7.org/linux/man-pages/man2/recv.2.html

#define BLOCKING_IO_RETURN_INT(FD, FUNC) {      \
    int ret;                                    \
    threadEntry_t self;                         \
    fdEntry_t *fdEntry = getFdEntry(FD);        \
    if (fdEntry == NULL) {                      \
        errno = EBADF;                          \
        return -1;                              \
    }                                           \
    do {                                        \
        startOp(fdEntry, &self);                \ <------
        ret = FUNC;                             \
        endOp(fdEntry, &self);                  \
    } while (ret == -1 && errno == EINTR);      \
    return ret;                                 \
}

When SocketInputStream in.read() fails to block?

SocketInputStream in.read() fails to block when the GC policy is set to gencon (default on Linux). For the other GC policies (balanced, metronome, nogc, optavgpause and optthruput), the test successfully passes.

Test output with debug code and -Xgcpolicy:gencon: Below, FUNC == recv doesn't block and immediately returns in the failing case.

inputstream class: java.net.SocketInputStream
in.read()---------------------------

in.read start: 2019-02-14 14:34:06.91
BLOCKING_IO_RETURN_INT enter FUNC ret: 0, errno: 2
BLOCKING_IO_RETURN_INT exit FUNC ret: 0, errno: 2
NET_Read fd: 6, bufP: , len: 1, nread: 0, errno: 2
SocketInputStream.read([b,I,I,I) socketRead: fd = java.io.FileDescriptor@b416428 n = 0
n = -1  <--- recv didn't block; in.read returned -1.
finally block - no SocketException thrown; count = 0

thread sleep start: 2019-02-14 14:34:06.91
thread sleep end: 2019-02-14 14:34:11.928 <--- Thread slept for 5 seconds
waking up---------------------------

s.close() ------------ done -----------

thr.join() ------------ done -----------

before pass/fail latch count = 0
******************************
Test: Socket.getInputStream().read()
Failed: Socket.getInputStream().read() wasn't preempted

Exception in thread "main" java.lang.Exception: 1 sub-tests failed - see log.
    at AsyncClose.main(AsyncClose.java:73)

Test output with debug code and -Xgcpolicy:metronome|balanced|nogc|optavgpause|optthruput: Below, FUNC == recv blocks until s.close() is invoked. After s.close() finishes, FUNC resumes code execution, and in.read() / NET_Read catches SocketException.

inputstream class: java.net.SocketInputStream
in.read()---------------------------

sleep 5000 begin---------------------------

in.read start: 2019-02-14 14:37:49.308
thread sleep start: 2019-02-14 14:37:49.308

BLOCKING_IO_RETURN_INT enter FUNC ret: 0, errno: 2

thread sleep end: 2019-02-14 14:37:54.323 <--- Thread slept for 5 seconds
waking up---------------------------

s.close() ------------ done -----------
BLOCKING_IO_RETURN_INT exit FUNC ret: -1, errno: 9
NET_Read fd: 6, bufP: , len: 1, nread: -1, errno: 9

java.net.SocketException: Socket closed
    at java.base/java.net.SocketInputStream.socketRead0(Native Method)
    at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:169)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:203)
    at Socket_getInputStream_read.run(Socket_getInputStream_read.java:67)
    at java.base/java.lang.Thread.run(Thread.java:825)
setting closed(): count = 0
finally, no SocketException thrown; count = 0
thr.join() ------------ done -----------

before pass/fail latch count = 0
******************************
Test: Socket.getInputStream().read()
Passed.

errno is set to 2 (ENOENT No such file or directory) while executing SocketInputStread in.read().

Tracked errno in gdb: watch *__errno_location(). errno changed at two places in GC code:

  1. Location 1 where errno changes to 2
    
    Thread 2 "java" hit Watchpoint 3: *__errno_location()

Old value = 0 New value = 2 0x00007fffef0584db in MM_CopyScanCacheChunk::initialize(MM_EnvironmentBase, unsigned long, MM_CopyScanCacheChunk, unsigned long, MM_CopyScanCacheStandard**) () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so (gdb) where

0 0x00007fffef0584db in MM_CopyScanCacheChunk::initialize(MM_EnvironmentBase, unsigned long, MM_CopyScanCacheChunk, unsigned long, MM_CopyScanCacheStandard**) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

1 0x00007fffef0586d6 in MM_CopyScanCacheChunk::newInstance(MM_EnvironmentBase, unsigned long, MM_CopyScanCacheChunk, MM_CopyScanCacheStandard**) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

2 0x00007fffef0522ed in MM_CopyScanCacheList::appendCacheEntries(MM_EnvironmentBase*, unsigned long) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

3 0x00007fffeeffdf6e in MM_Scavenger::initialize(MM_EnvironmentBase*) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

4 0x00007fffeeffeeb5 in MM_Scavenger::newInstance(MM_EnvironmentStandard, MM_HeapRegionManager) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

5 0x00007fffeeff59c3 in MM_ConfigurationGenerational::createDefaultMemorySpace(MM_EnvironmentBase, MM_Heap, MM_InitializationParameters*) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

6 0x00007fffeeec933e in internalAllocateMemorySpaceWithMaximumWithEnv ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

7 0x00007fffeeec9976 in internalAllocateMemorySpaceWithMaximum () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

8 0x00007fffeeebbda0 in gcInitializeHeapStructures () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

9 0x00007fffeee99958 in J9VMDllMain () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

10 0x00007ffff605dc62 in runJ9VMDllMain () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

11 0x00007ffff60f9d68 in pool_do () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

12 0x00007ffff5fb33a1 in runInitializationStage () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

13 0x00007ffff606602d in protectedInitializeJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

14 0x00007ffff5425e60 in omrsig_protect () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9prt29.so

15 0x00007ffff6060604 in initializeJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

16 0x00007ffff60570b4 in J9_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

17 0x00007ffff656b879 in JNI_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libjvm.so

18 0x00007ffff6fb647a in JNI_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/j9vm/libjvm.so

19 0x00007ffff7bcabe6 in InitializeJVM (ifn=, penv=0x7ffff6fa9ef8, pvm=0x7ffff6fa9ef0) at /root/openj9-openjdk-jdk11/src/java.base/share/native/libjli/java.c:1527

20 JavaMain (_args=) at /root/openj9-openjdk-jdk11/src/java.base/share/native/libjli/java.c:414

21 0x00007ffff71c86ba in start_thread (arg=0x7ffff6faa700) at pthread_create.c:333

22 0x00007ffff790341d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

2. Location 2 where `errno` changes to 2

Thread 2 "java" hit Watchpoint 4: *__errno_location()

Old value = 0 New value = 2 0x00007ffff78fd6c0 in __mmap (addr=addr@entry=0x0, len=len@entry=1622016, prot=prot@entry=3, flags=flags@entry=34, fd=fd@entry=-1, offset=offset@entry=0) at ../sysdeps/unix/sysv/linux/wordsize-64/mmap.c:34 34 ../sysdeps/unix/sysv/linux/wordsize-64/mmap.c: No such file or directory. (gdb) where

0 0x00007ffff78fd6c0 in __mmap (addr=addr@entry=0x0, len=len@entry=1622016, prot=prot@entry=3, flags=flags@entry=34, fd=fd@entry=-1, offset=offset@entry=0) at ../sysdeps/unix/sysv/linux/wordsize-64/mmap.c:34

1 0x00007ffff787daff in sysmalloc (nb=nb@entry=1618160, av=av@entry=0x7ffff0000020) at malloc.c:2323

2 0x00007ffff787e743 in _int_malloc (av=av@entry=0x7ffff0000020, bytes=bytes@entry=1618144) at malloc.c:3827

3 0x00007ffff7880184 in __GI___libc_malloc (bytes=1618144) at malloc.c:2913

4 0x00007ffff544bcf0 in omrmem_allocate_memory () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9prt29.so

5 0x00007fffeefa86bc in OMR::GC::Forge::allocate(unsigned long, OMR::GC::AllocationCategory::Enum, char const*) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

6 0x00007fffef04b4be in MM_CopyScanCacheChunk::newInstance(MM_EnvironmentBase, unsigned long, MM_CopyScanCacheChunk, MM_CopyScanCacheStandard**) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

7 0x00007fffef04511d in MM_CopyScanCacheList::appendCacheEntries(MM_EnvironmentBase*, unsigned long) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

8 0x00007fffeeff0bbe in MM_Scavenger::initialize(MM_EnvironmentBase*) () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

9 0x00007fffeeff1b43 in MM_Scavenger::newInstance(MM_EnvironmentStandard, MM_HeapRegionManager) () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

10 0x00007fffeefe8613 in MM_ConfigurationGenerational::createDefaultMemorySpace(MM_EnvironmentBase, MM_Heap, MM_InitializationParameters*) ()

from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

11 0x00007fffeeec141d in internalAllocateMemorySpaceWithMaximumWithEnv () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

12 0x00007fffeeec1a98 in internalAllocateMemorySpaceWithMaximum () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

13 0x00007fffeeeb3f83 in gcInitializeHeapStructures () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

14 0x00007fffeee92798 in J9VMDllMain () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9gc29.so

15 0x00007ffff60588e3 in runJ9VMDllMain () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

16 0x00007ffff60f06c8 in pool_do () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

17 0x00007ffff5fbf355 in runInitializationStage () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

18 0x00007ffff6060a08 in protectedInitializeJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

19 0x00007ffff54312f0 in omrsig_protect () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9prt29.so

20 0x00007ffff605b1ad in initializeJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

21 0x00007ffff6051ed5 in J9_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libj9vm29.so

22 0x00007ffff656b347 in JNI_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/compressedrefs/libjvm.so

23 0x00007ffff6fb6256 in JNI_CreateJavaVM () from /root/openj9-openjdk-jdk11/build/linux-x86_64-normal-server-release/images/jdk/lib/j9vm/libjvm.so

24 0x00007ffff7bcabe6 in InitializeJVM (ifn=, penv=0x7ffff6fa9ef8, pvm=0x7ffff6fa9ef0) at /root/openj9-openjdk-jdk11/src/java.base/share/native/libjli/java.c:1527

25 JavaMain (_args=) at /root/openj9-openjdk-jdk11/src/java.base/share/native/libjli/java.c:414

26 0x00007ffff71c86ba in start_thread (arg=0x7ffff6faa700) at pthread_create.c:333

27 0x00007ffff790341d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109



The test passes with OpenJ9 JDK8, and `errno` is always set to 0 in OpenJ9 JDK8.

The test fails with OpenJ9 JDK11, and `errno` changes to 2 while running GC code. The failure is only seen with the `gencon` GC policy.

OpenJ9 doesn't implement Java/native code for `java.net.Socket`, `SocketInputStream` and its dependencies. `openj9-openjdk-jdk11` has the Java/native implementation for `java.net.*`.

fyi - @ChengJin01. Adding GC team members to investigate further: @dmitripivkine @amicic.
dmitripivkine commented 5 years ago

I don't see how this relates to GC code. Requested memory size is reasonable. One of this points is in Port Library. Another one relates to initialization of allocated memory and again size is correct so there is no out-of-bound writes

adamfarley commented 5 years ago

A similar bug has been seen on macosx on jdk8.

https://github.com/eclipse/openj9/issues/5139

Expanding the excludes in jdk8 and 11 to include all platforms.