7168110: Misleading jstack error message
authorrobm
Thu, 17 May 2012 22:42:32 +0100
changeset 12698 8d48f8005004
parent 12697 79006a8e17dd
child 12699 6142d1da5851
7168110: Misleading jstack error message Reviewed-by: alanb, dsamersoff
jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Thu May 17 06:26:05 2012 -0700
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Thu May 17 22:42:32 2012 +0100
@@ -466,7 +466,17 @@
         }
         CloseHandle(hThread);
     } else {
-        JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed");
+        if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
+            //
+            // This error will occur when attaching to a process belonging to
+            // another terminal session. See "Remarks":
+            // http://msdn.microsoft.com/en-us/library/ms682437%28VS.85%29.aspx
+            //
+            JNU_ThrowIOException(env,
+                "Insufficient memory or insufficient privileges to attach");
+        } else {
+            JNU_ThrowIOExceptionWithLastError(env, "CreateRemoteThread failed");
+        }
     }
 
     VirtualFreeEx(hProcess, pCode, 0, MEM_RELEASE);