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

StackOverflowError on open WindowsPreferences

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b10
    • CPU:
      x86_64
    • OS:
      windows
    • Verification:
      Verified

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        On every Windows from Java version 8 to 16.

        A DESCRIPTION OF THE PROBLEM :
        java.lang.StackOverflowError
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.prefs.AbstractPreferences.isUserNode(Unknown Source)
        at java.util.prefs.WindowsPreferences.rootNativeHandle(Unknown Source)
        at java.util.prefs.WindowsPreferences.<init>(Unknown Source)
        at java.util.prefs.WindowsPreferences.getUserRoot(Unknown Source)
        at java.util.prefs.WindowsPreferencesFactory.userRoot(Unknown Source)
        at java.util.prefs.Preferences.userRoot(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.prefs.AbstractPreferences.isUserNode(Unknown Source)
        at java.util.prefs.WindowsPreferences.rootNativeHandle(Unknown Source)
        at java.util.prefs.WindowsPreferences.<init>(Unknown Source)
        at java.util.prefs.WindowsPreferences.getUserRoot(Unknown Source)
        at java.util.prefs.WindowsPreferencesFactory.userRoot(Unknown Source)
        at java.util.prefs.Preferences.userRoot(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.prefs.AbstractPreferences.isUserNode(Unknown Source)
        at java.util.prefs.WindowsPreferences.rootNativeHandle(Unknown Source)
        at java.util.prefs.WindowsPreferences.<init>(Unknown Source)
        at java.util.prefs.WindowsPreferences.getUserRoot(Unknown Source)
        at java.util.prefs.WindowsPreferencesFactory.userRoot(Unknown Source)
        at java.util.prefs.Preferences.userRoot(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)
        at java.util.prefs.AbstractPreferences$1.run(Unknown Source)

        The problem is that the error handler is not using the parameter of the constructor. Else it is calling a function that trigger the constructor again.

            private WindowsPreferences(long rootNativeHandle, byte[] rootDirectory) {
                super(null, "");
                long[] result =
                        WindowsRegCreateKeyEx1(rootNativeHandle, rootDirectory);
                if (result[ERROR_CODE] != ERROR_SUCCESS) {
                    logger().warning("Could not open/create prefs root node " +
                            byteArrayToString(windowsAbsolutePath()) +
                            " at root 0x" + Long.toHexString(rootNativeHandle()) +
                            ". Windows RegCreateKeyEx(...) returned error code " +
                            result[ERROR_CODE] + ".");
                    isBackingStoreAvailable = false;
                    return;
                }
                // Check if a new node
                newNode = (result[DISPOSITION] == REG_CREATED_NEW_KEY);
                closeKey(result[NATIVE_HANDLE]);
            }

        In the code rootNativeHandle() should be replaces with rootNativeHandle. Removing the parentheses should solve the StackOverflowError and show the real error.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        calling Preferences.userRoot() if no access rights to the registry


        CUSTOMER SUBMITTED WORKAROUND :
        Give the user more access right to the user of the Java process.

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: