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

libJdbcOdbc.so has a dependency of libjava.so which isn't being done in build

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • 1.1.8_003
    • 1.1.8
    • infrastructure
    • None
    • b03
    • sparc
    • solaris_2.6
    • Verified

      Customer is running their application and getting the following error on
      Solaris O/S using the JavaSoft Reference Implementation 1.1.8:

      Aug 25 9:18:30 1999: ld.so.1: /work2/jaguar35/bin/jagsrv: fatal: relocation
      error: file
      /wok2/jaguar35/jdk/jdk_latest/lib/sparc/native_threads/libJdbcOdbc.so: symbol
      makeCString:referenced symbol not found (libJdbcOdbc.so)

      Looking at libJdbcOdbc.so which is located:

        /net/mizu.eng/export2/jdk/1.1.8/m/binary/solaris/lib/sparc/native_threads

      You see that makeCString is not found:

          donald% ldd -d libJdbcOdbc.so
      libodbcinst.so.1 => (file not found)
      libodbc.so.1 => (file not found)
      libthread.so.1 => /usr/lib/libthread.so.1
      libdl.so.1 => /usr/lib/libdl.so.1
      libc.so.1 => /usr/lib/libc.so.1
      /usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1
      symbol not found: SQLAllocConnect (./libJdbcOdbc.so)
              ...
      symbol not found: makeCString (./libJdbcOdbc.so)
      symbol not found: makeCString (./libJdbcOdbc.so)

      This symbol is located in libjava.so. If the JDK was built with
      libJdbcOdbc.so having the dependency of libjava.so (build it
      with "-z defs" argument to see which symbols not defined) then link
      in correct library, the symbol would be defined when customer runs their app
      and the library would be available.

      Customer does a dlopen() of libjava.so in his library libjjdk11.7.so with
      a scope of RTLD_LOCAL.

      13018: 1: file=libjjdk117.so; dlopen() called from
      file=/work2/jaguar35/lib/libjaf_r.so [ RTLD_LOCAL RTLD_LAZY ]
      ......
      13018: 1: file=libjava.so; needed by /work2/jaguar35/lib/libjjdk117.so

      Then later when libJdbcOdbc.so is accessed, it can't
      see the symbols it needs from libjava.so because they have local scope,
      resulting in above "relocation error."

      Email from Rod Evans:

      "When an object is dlopen'ed it has a `local' scope. This scope is also
      given to any of its dependencies. Thus the `group' of objects loaded
      as a result of one dlopen() all have the same scope and can find symbols
      within each other. In your scenario you have two dlopen groups. Different
      groups are not allowed to locate symbols between each other. Groups can
      have the same objects, and you establish your objects from having the
      correct dependencies."


      Customer can not change the scope from RTLD_LOCAL to RTLD_GLOBAL as this
      will cause symbol collisions with the other libraries he is using in his
      app.

      -------------------

      Testcase:

      test.c:

        #include <dlfcn.h>

        main()
        {
              if (dlopen("libjava.so", RTLD_LAZY) == 0) {
                      printf("libjava.so failed: %s\n", dlerror());
                      return (1);
              }
              if (dlopen("libJdbcOdbc.so", RTLD_LAZY) == 0) {
                      printf("libJdbcOdbc.so failed: %s\n", dlerror());
                      return (1);
              }
              return (0);
        }

      ** This will dlopen with a default of RTLD_LOCAL.**

      TO COMPILE:

            donald%cc -o main main.c -ldl -lthread

      TO SET UP LD_LIBRARY_PATH:

      donald% echo $LD_LIBRARY_PATH
      /net/mizu.eng/export2/jdk/1.1.8/m/binary/solaris/lib/sparc/native_threads:/home/margotm/lib

      TO RUN PROGRAM AND GET OUTPUT:

        donald% main
        libJdbcOdbc.so failed: ld.so.1: main: fatal: relocation error: file
      /net/mizu.eng/export2/jdk/1.1.8/m/binary/solaris/lib/sparc/native_threads/
        libJdbcOdbc.so: symbol makeCString: referenced symbol not found
        Segmentation Fault

      After licJdbcOdbc.so is built with the dependency of libjava.so the above
      program should work.

      margot.miller@Eng 1999-09-03

            duke J. Duke
            margmill Margot Miller (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: