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

SafeFetch may crash if invoked in non-JavaThreads

    XMLWordPrintable

Details

    • b02

    Backports

      Description

        In our primary hotspot signal handlers, SafeFetch handling is limited to JavaThread objects:

        ```
          JavaThread* thread = NULL;
        ...
          if(t->is_Java_thread()) {
            thread = (JavaThread*)t;
          }
        ...
          if (info != NULL && uc != NULL && thread != NULL) {
            pc = (address) os::Linux::ucontext_get_pc(uc);
            if (StubRoutines::is_safefetch_fault(pc)) {
        ```

        As a result of this, using SafeFetch may crash non-JavaThreads if the location is invalid. E.g. using SafeFetch inside a VMOperation may crash the VM.

        This is unfortunate since SafeFetch is used for os::is_readable_pointer() which explicitly promises to not crash. It is used e.g. in os::print_hex_dump(). There is also no reason why SafeFetch would not work for non-JavaThreads. In fact, SafeFetch handling for the secondary signal handler works just fine for all threads.

        This is an old bug, unrelated to the recent Posix cleanups. AFAICS it has been there at least since Jdk11.

        Attachments

          Issue Links

            Activity

              People

                stuefe Thomas Stuefe
                stuefe Thomas Stuefe
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: