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

-Xss not multiple of 4K does not work for the main thread on macOS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u231, 11.0.5, 13.0.1, 14, 15
    • Fix Version/s: 19
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b26
    • OS:
      os_x

      Backports

        Description

        I came across this issue when answering the question at
        https://stackoverflow.com/questions/59518898/why-doesnt-larger-xss-give-bigger-maximum-stack-depth

        The above example shows that the effect of -Xss160k is completely different from -Xss159k and -Xss161k.

        -Xss argument is processed twice: first by the launcher, then by the JVM. The launcher (libjli/java_md_solinux.c) simply calls pthread_attr_setstacksize(&attr, stack_size) without preprocessing the argument.

        The behavior of pthread_attr_setstacksize differs on Linux and Mac OS X. E.g. the documentation https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/pthread_attr_setstacksize.3.html explicitly says that the function returns EINVAL, if stacksize is not a multiple of the system page size. The launcher silently ignores the error and continues with the default stack size. So, even if I run java -Xss3333k, the main thread will still have 512 KB stack size on macOS.

        HotSpot, however, rounds ThreadStackSize to the page boundary, so new threads will have the correctly adjusted stack size.

        The suggested fix is to round Xss in the launcher, too, in order to have the consistent behavior between main and other threads on all platforms.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                asotona Adam Sotona
                Reporter:
                apangin Andrei Pangin
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: