Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8222242

Use qemu user mode run MIPS arch on host x86_64 nio.Nativethread init failed

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      ADDITIONAL SYSTEM INFORMATION :
      host env:
       4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

      qemu user env:
      4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 mips64 GNU/Linux

      java version(in qemu user mode):
      openjdk version "1.8.0_151"
      OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1-b12)


      A DESCRIPTION OF THE PROBLEM :
      We used qemu user mode to run MIPS64 arch based on a host environment(OS: ubuntu 18.04 with kernel 4.15.0-46, CPU: X86_64). And when we tried to use Ant in qemu user mode to build a java project, it always failed with the last several levels in call stack info as below:
      java.lang.ArrayIndexOutOfBoundsException: -1
      at sun.nio.ch.NativeThreadSet.remove(NativeThreadSet.java:76)
      at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:163)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
      at java.io.InputStream.read(InputStream.java:101)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:81)

      We found the root cause is:
      In MIPS arch the __SIGRTMAX is defined to 128 but in X86 arch its value is 64.when openjdk be built this value is fixed by depend on different CPU archs, in file ..\jdk\src\solaris\native\sun\nio\ch\NativeThread.c
      /* Also defined in src/solaris/native/java/net/linux_close.c */
      #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)

      then in function JNIEXPORT void JNICALLJava_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
      it sends the signal and throws a exception if sigaction() fail.
      if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
              JNU_ThrowIOExceptionWithLastError(env, "sigaction");

      So when we use the openjdk which built in the system with CPU arch is MIPS this INTERRUPT_SIGNAL has been fixed to 126. Then in this scenario"qemu user mode run MIPS on host X86_64 CPU env" NativeThread init will never success.

      Is it possible to set a const value for INTERRUPT_SIGNAL that all CPUs could support?


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: