8282712: VMConnection.open() does not detect if VM failed to be created, resulting in NPE

Reviewed-by: sspitsyn, amenkov
This commit is contained in:
Chris Plummer 2023-08-17 15:09:09 +00:00
parent e8f6b3e497
commit 388dcff725
2 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -544,16 +544,18 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
MessageOutput.fatalError("Unable to launch target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
MessageOutput.fatalError("Internal debugger error.");
throw new RuntimeException(icae);
} catch (VMStartException vmse) {
MessageOutput.println("vmstartexception", vmse.getMessage());
MessageOutput.println();
dumpFailedLaunchInfo(vmse.process());
MessageOutput.fatalError("Target VM failed to initialize.");
throw new RuntimeException(vmse);
}
return null; // Shuts up the compiler
}
/* attach to running target vm */
@ -564,11 +566,12 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
MessageOutput.fatalError("Unable to attach to target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
MessageOutput.fatalError("Internal debugger error.");
throw new RuntimeException(icae);
}
return null; // Shuts up the compiler
}
/* listen for connection from target vm */
@ -583,10 +586,11 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
MessageOutput.fatalError("Unable to attach to target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
MessageOutput.fatalError("Internal debugger error.");
throw new RuntimeException(icae);
}
return null; // Shuts up the compiler
}
}

View File

@ -322,15 +322,17 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
System.err.println("\n Unable to launch target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
System.err.println("\n Internal debugger error.");
throw new RuntimeException(icae);
} catch (VMStartException vmse) {
System.err.println(vmse.getMessage() + "\n");
dumpFailedLaunchInfo(vmse.process());
System.err.println("\n Target VM failed to initialize.");
throw new RuntimeException(vmse);
}
return null; // Shuts up the compiler
}
/* attach to running target vm */
@ -341,11 +343,12 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
System.err.println("\n Unable to attach to target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
System.err.println("\n Internal debugger error.");
throw new RuntimeException(icae);
}
return null; // Shuts up the compiler
}
/* listen for connection from target vm */
@ -360,10 +363,11 @@ class VMConnection {
} catch (IOException ioe) {
ioe.printStackTrace();
System.err.println("\n Unable to attach to target VM.");
throw new RuntimeException(ioe);
} catch (IllegalConnectorArgumentsException icae) {
icae.printStackTrace();
System.err.println("\n Internal debugger error.");
throw new RuntimeException(icae);
}
return null; // Shuts up the compiler
}
}