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

Linux: do not use alternate signal stack

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 5.0
    • hotspot
    • None
    • b22
    • generic
    • linux

      Alternate signal stack is used on Linux to support stack banging.

      Stack banging needs to touch page below current ESP; however, this will
      generate SIGSEGV on Linux. To work around the problem, we install alternate
      signal stack for SIGSEGV at the lower end of thread stack. When we receive
      a SEGV due to stack bang, we will touch the same page again from SEGV
      handler. Because we are now running on alternate signal stack with a smaller
      ESP, this time we can succeed.

      There are other ways to get around the problem without using alt signal
      stack:

      1. mmap() the page directly. This may have some performance issue, as mmap()
         on old systems will create a new memory region. Using mmap() for stack
         bang may create too many memory regions. With Tiger, we'll drop some old
         systems, so we might be able to use mmap(). Need to test.
      2. Temporarily adjust ESP to lower address within SEGV handler. However, when
         stack space is already low, and if there's another signal delivered after
         SEGV, changing ESP might leave too little space to handle the new signal.
         We can get around this by temporarily masking all signals.

      Here are the benefits from not using alternate signal stack:

      1. Allow smaller thread stack, and more threads. Currently, every thread
         needs 40K alternate signal stack, minimum stack size is 96K. Removing alt
         signal stack can reduce minimum stack size by about 40%.
      2. Only need one set of guard pages. Right now, we have HotSpot guard pages
         between alt signal stack and normal thread stack, and regular glibc guard
         page below alt signal stack. We don't need glibc guard pages when there
         is not alternate signal stack. HotSpot guard pages are enough. Creating
         guard page on Linux is very expensive. Using a micro benchmark, not
         creating glibc guard (or HotSpot guard) can reduce thread creation time
         by about 40%.
      3. Easier to maintain. Same model on all platforms.

      ###@###.### 2003-04-23

            hhuangsunw Hui Huang (Inactive)
            hhuangsunw Hui Huang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: