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

Launcher can not find path to libpackager.so

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_92"
        Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
        Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)


        However, this is irrelevant, as bug is caused by C++ code before JVM ist even started.

        ADDITIONAL OS VERSION INFORMATION :
        Linux 3.19.0-32-generic (amd64)

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Linux is _not_ running in a VM. Apparently freshly allocated memory on some VMs is pre-initialized to NULL bytes.

        A DESCRIPTION OF THE PROBLEM :
        The Linux launcher (http://hg.openjdk.java.net/openjfx/8u-dev/rt/file/922957ec457e/modules/fxpackager/src/main/native/launcher/linux/launcher.cpp) determines its own path by invoking:

          readlink("/proc/self/exe", buffer, MAX_PATH - 1)

        However the c string created from this buffer is not correctly terminated, thus random contents from the buffer will become part of the path:

          buffer[MAX_PATH - 1] = '\0';

        The correct position to append the NULL byte (i.e. the string length) would be returned by readlink, however this return value is not stored.

        An example for correct usage is given in the readlink manpages (http://linux.die.net/man/3/readlink):

          ssizet_t len;
          if ((len = readlink("/modules/pass1", buf, sizeof(buf)-1)) != -1)
              buf[len] = '\0';

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Start launcher binary, that has been created by the JavaFX Packager.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Launcher can find libpackager.so and starts the JavaFX application.
        ACTUAL -
        Launcher can not find libpackager.so, as it searches in the wrong path.

        Instead of "/opt/ApplicationName/libpackager.so" there are additional random characters appended after "/opt/ApplicationName/".

        A concrete example is available on https://github.com/cryptomator/cryptomator/issues/265

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        /opt/Cryptomator/Cryptomatorn/libpackager.so not found.

        REPRODUCIBILITY :
        This bug can be reproduced often.

        CUSTOMER SUBMITTED WORKAROUND :
        Unpack packager-created packages, replace launcher by custom implementation, repackage manually.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vdrozdov Victor Drozdov (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: