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

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • tools
    • None
    • behavioral
    • low
    • Hide
      In rare cases where

      1. the system require stack size to be multiple of system page size, and
      2. the stack size specified is smaller than default stack size, and
      3. the stack size specified is not multiple of system page size, and
      4. the program actually need a larger stack size than specified

      The program may fail with java.lang.StackOverflowError under the new behavior.

      Show
      In rare cases where 1. the system require stack size to be multiple of system page size, and 2. the stack size specified is smaller than default stack size, and 3. the stack size specified is not multiple of system page size, and 4. the program actually need a larger stack size than specified The program may fail with java.lang.StackOverflowError under the new behavior.
    • Other
    • JDK

      Summary

      The launcher should round up the stack size specified with the -Xss option to a multiple of the system page size as required by the operating system.

      Problem

      The Java launcher use pthread_attr_setstacksize to set the stack size of the initial thread on POSIX systems. On some systems, like MacOS, the stack size is required to be a multiple of the system page size; otherwise, the call will fail and lead to use of the default stack size.

      Solution

      The launcher will try to set the stack size with the specified value. In case that fails, the launcher will round up the specified stack size to a multiple of the system page size and try again.

      Specification

      java -X says about -Xss option:

      -Xss<size>        set java thread stack size

      will be changed to

      -Xss<size>        set java thread stack size
                        The actual size may be rounded up to a multiple of the system
                        page size as required by the operating system.

            henryjen Henry Jen
            apangin Andrei Pangin
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: