changeset 5040:c528acec8bba

7168110: Misleading jstack error message Reviewed-by: alanb, dsamersoff
author robm
date Thu, 17 May 2012 22:42:32 +0100
parents 7e2de40cb062
children 3562fc7500a4
files src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Mon May 28 19:06:08 2012 +0400
+++ b/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);