Skip to content

Commit

Permalink
8282712: VMConnection.open() does not detect if VM failed to be creat…
Browse files Browse the repository at this point in the history
…ed, resulting in NPE

Reviewed-by: sspitsyn, amenkov
  • Loading branch information
plummercj committed Aug 17, 2023
1 parent e8f6b3e commit 388dcff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -544,16 +544,18 @@ private VirtualMachine launchTarget() {
} 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 */
Expand All @@ -564,11 +566,12 @@ private VirtualMachine attachTarget() {
} 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 */
Expand All @@ -583,10 +586,11 @@ private VirtualMachine listenTarget() {
} 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
}
}
10 changes: 7 additions & 3 deletions test/jdk/com/sun/jdi/VMConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,17 @@ private VirtualMachine launchTarget() {
} 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 */
Expand All @@ -341,11 +343,12 @@ private VirtualMachine attachTarget() {
} 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 */
Expand All @@ -360,10 +363,11 @@ private VirtualMachine listenTarget() {
} 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
}
}

1 comment on commit 388dcff

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.