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

libjsig is not getting preloaded correctly on solaris sparc

XMLWordPrintable

    • sparc
    • solaris

      ADDITIONAL SYSTEM INFORMATION :
      SunOS 5.11 11.3 sun4v sparc sun4v
      jdk-11.0.20

      A DESCRIPTION OF THE PROBLEM :
      In our application we call a native (c) code from our java code using jni. Since the native code is used to allocate memory, we replaces the default signal handlers with our own implementation. To do so, we use the LD_PRELOAD_64 environment variable on solaris sparc and set it to 'libjsig.so'. The library is getting linked but the symbol 'JVM_begin_signal_setting' cannot be found.

      Using the LD_DEBUG=all environment variable on Solaris we could see the following:

      20755: file=libjsig.so; preloading
      20755: find object=libjsig.so; searching
      20755: trying path=<..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so [ ELF ]; generating link map
      20755: file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so; analyzing [ RTLD_LAZY RTLD_GLOBAL RTLD_WORLD RTLD_NODELETE ]
      20755: file=libc.so.1; needed by <..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: search path=$ORIGIN (RUNPATH/RPATH from file <..>/solaris_sparc_64/jre/lib/server/libjsig.so)
      20755: version needed processing: file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: file=libdl.so.1; needed by <..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: search path=$ORIGIN (RUNPATH/RPATH from file <..>/solaris_sparc_64/jre/lib/server/libjsig.so)
      20755: version needed processing: file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: relocation processing: file=/<..>/solaris_sparc_64/jre/lib/server/libjsig.so
      20755: relocation processing: file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so; finished


      So the library is getting preloaded.
      Java will then check if the library is preloaded by trying to get a pointer to the method "JVM_begin_signal_setting". This will result in a fatal error:

      20755: 2: symbol=JVM_begin_signal_setting; dlsym() called from file=<..>/solaris_sparc_64/jre/lib/server/libjvm.so [ RTLD_DEFAULT ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/bin/java [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/sparcv9/libc.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/sparcv9/libz.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/bin/../lib/jli/libjli.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/sparcv9/libthread.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/sparcv9/libdl.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/server/libjvm.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libm.so.2 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libsocket.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/usr/lib/64/libsched.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libdoor.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/usr/lib/64/libdemangle.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libnsl.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/librt.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libkstat.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/usr/lib/64/libCrun.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libmp.so.2 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libucrypto.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libcryptoutil.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libelf.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/libverify.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/libjava.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libscf.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/libjimage.so [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libuutil.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libgen.so.1 [ ELF ]
      20755: 2: symbol=JVM_begin_signal_setting; lookup in file=/lib/64/libnvpair.so.1 [ ELF ]
      20755: 2: ld.so.1: java: fatal: JVM_begin_signal_setting: can't find symbol

      The problem seems to be that the symbols are not getting exported correctly.
      I cannot configure the jdk Makefile on our local solaris server that's why I cannot be more specific about the problem ... sorry
      I have tried using the libjsig.so from jdk-8 and it has worked without a problem. So the problem is specific to jdk-11 and Solaris Sparc.











      REGRESSION : Last worked in version 8u381

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      13201: 2: symbol=JVM_begin_signal_setting; dlsym() called from file=<..>/solaris_sparc_64/jre/lib/server/libjvm.so [ RTLD_DEFAULT ]
      13201: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/bin/java [ ELF ]
      13201: 2: symbol=JVM_begin_signal_setting; lookup in file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so [ ELF ]
      13201: 2: binding file=<..>/solaris_sparc_64/jre/lib/server/libjvm.so to file=<..>/solaris_sparc_64/jre/lib/server/libjsig.so: symbol 'JVM_begin_signal_setting'
      ACTUAL -
      ld.so.1: java: fatal: JVM_begin_signal_setting: can't find symbol

      CUSTOMER SUBMITTED WORKAROUND :
      We have compiled libjsig using the following commands:

      gcc -g0 -O3 -fno-strict-aliasing -Wall -fmessage-length=0 -pthreads -mcpu=v9 -fPIC -m64 -Wno-unused-function -c jsig.c -o jsig.o
      gcc -shared -olibjsig.so jsig.o -fPIC -m64



      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: