6415680: (bf) MappedByteBuffer.get() can provoke crash with EXCEPTION_IN_PAGE_ERROR
authorjcm
Wed, 15 Nov 2017 00:49:57 -0800
changeset 47892 895fddb973a1
parent 47891 fa736014cf28
child 47893 ef2e9b041e32
6415680: (bf) MappedByteBuffer.get() can provoke crash with EXCEPTION_IN_PAGE_ERROR Summary: Made changes in topLevelExceptionFilter for handling unsafe single value invalid memory access failures, equivalent of JDK-4454115. Reviewed-by: dholmes, dlong
src/hotspot/os/windows/os_windows.cpp
--- a/src/hotspot/os/windows/os_windows.cpp	Tue Nov 14 18:08:35 2017 -0800
+++ b/src/hotspot/os/windows/os_windows.cpp	Wed Nov 15 00:49:57 2017 -0800
@@ -2487,6 +2487,20 @@
     } // /EXCEPTION_ACCESS_VIOLATION
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+    if (exception_code == EXCEPTION_IN_PAGE_ERROR) {
+      CompiledMethod* nm = NULL;
+      JavaThread* thread = (JavaThread*)t;
+      if (in_java) {
+        CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
+        nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
+      }
+      if ((thread->thread_state() == _thread_in_vm &&
+          thread->doing_unsafe_access()) ||
+          (nm != NULL && nm->has_unsafe_access())) {
+        return Handle_Exception(exceptionInfo, SharedRuntime::handle_unsafe_access(thread, (address)Assembler::locate_next_instruction(pc)));
+      }
+    }
+
     if (in_java) {
       switch (exception_code) {
       case EXCEPTION_INT_DIVIDE_BY_ZERO: