-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8310380: Handle problems in core-related tests on macOS when codesign tool does not work #14562
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
@MBaesken The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks for enhancing test analysis.
@MBaesken This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 100 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few review suggestions. Does the symptom happen on both, arm64 and x64?
@@ -148,6 +150,11 @@ public static String getCoreFileLocation(String crashOutputString, long pid) thr | |||
// We can't generate cores files with hardened binaries on OSX 10.15 and later. | |||
throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later"); | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could do just one case here:
else if (!Platform.hasPlistEntriesOSX()) {
...
public static boolean hasPlistEntriesOSX() throws IOException { | ||
// Find the path to the java binary. | ||
String jdkPath = System.getProperty("java.home"); | ||
Path javaPath = Paths.get(jdkPath + "/bin/java"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do it more concisely:
Path javaPath = Paths.get(System.getProperty("java.home") + "/bin/java");
if (Files.notExists(javaPath)) {
throw new FileNotFoundException("Could not find file " + javaPath.toAbsolutePath().toString());
} | ||
|
||
// Run codesign on the java binary. | ||
ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then here 'ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaPath.toAbsolutePath().toString());`
ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName); | ||
pb.redirectErrorStream(true); // redirect stderr to stdout | ||
Process codesignProcess = pb.start(); | ||
BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do the BufferedReader stuff in a try-with-resources and then return false instead of potentially throwing an IOException?
BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream())); | ||
String line; | ||
while ((line = is.readLine()) != null) { | ||
System.out.println("STDOUT: " + line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This output is for every line seems too much. Maybe just print the lines where you find "Info.plist=not bound" or "Info.plist entries="?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the output useful when analyzing the issue (and it is just a few lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyrights need updating.
return true; | ||
} | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably would be good to log that no Info.plist entry was found.
@@ -127,6 +127,8 @@ public static String getCoreFileLocation(String crashOutputString, long pid) thr | |||
} | |||
|
|||
return coreFileLocation; // success! | |||
} else { | |||
System.out.println("Core file not found, try to find a reason for this"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.out.println("Core file not found, try to find a reason for this"); | |
System.out.println("Core file not found. Trying to find a reason why..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the message.
test/lib/jdk/test/lib/Platform.java
Outdated
@@ -260,6 +260,34 @@ public static boolean hasSA() { | |||
return true; | |||
} | |||
|
|||
|
|||
public static boolean hasPlistEntriesOSX() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost all of this is replicated from isHardenedOSX()
. I wonder if there is a way to do some sharing while still maintaining separate APIs. Combining them into one API might make it harder to understand the code. Maybe a launchCodesign()
API that returns the BufferedReader would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyrights need updating.
|
I adjusted COPYRIGHT info, adjusted TestMutuallyExclusivePlatformPredicates.java . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a bit better. But I think instead of adding a Utils.javaPath() method, you can do all this path handling in Platform.launchCodesignOnJavaBinary(). Then even more code would be shared.
test/lib/jdk/test/lib/Platform.java
Outdated
@@ -260,6 +260,36 @@ public static boolean hasSA() { | |||
return true; | |||
} | |||
|
|||
private static codesignProcess launchCodesignOnJavaBinary(String javaFileName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can't work... should be private static Process
😉
Yes it must be 'private static Process' . And I moved the javaPath method into the caller , |
Okay, I had the idea to later use the method javaPath at some more places, but let's do this separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now.
Hi Christoph, thanks for the review ! |
Sorry, I've been on vacation the past few days. I will have a look at it tomorrow. |
test/lib/jdk/test/lib/Platform.java
Outdated
return codesignProcess; | ||
} | ||
|
||
public static boolean hasPlistEntriesOSX() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I understand why you chose this API name (it mimics the form used for isHardenedOSX
), I don't think it is a good choice. isHardenedOSX
is short for "is this a hardened OSX system". That mapping does not work with hasPlistEntriesOSX
, which is more like "does this OSX system have plist entries". I would suggest hasOSXPlistEntries
.
@@ -148,6 +150,11 @@ public static String getCoreFileLocation(String crashOutputString, long pid) thr | |||
// We can't generate cores files with hardened binaries on OSX 10.15 and later. | |||
throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later"); | |||
} | |||
} else { | |||
// codesign has to add entitlements using the plist, if this is not present we might not generate a core file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// codesign has to add entitlements using the plist, if this is not present we might not generate a core file | |
// codesign has to add entitlements using the plist. If this is not present we might not generate a core file. |
Hi Chris, I renamed the method and adjusted the comment. |
Thanks for the review ! /integrate |
Going to push as commit 39c104d.
Your commit was automatically rebased without conflicts. |
Currently, a number of tests fail on macOS because they miss the core file (e.g. serviceability/sa/TestJmapCore.java).
The reason is that configure detects on some setups that codesign does not work ("checking if debug mode codesign is possible... no) .
So adding the needed entitlement to generate cores is not done in the build. This is currently not checked later in the tests.
But without the entitlement, a core is not generated.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14562/head:pull/14562
$ git checkout pull/14562
Update a local copy of the PR:
$ git checkout pull/14562
$ git pull https://git.openjdk.org/jdk.git pull/14562/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14562
View PR using the GUI difftool:
$ git pr show -t 14562
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14562.diff
Webrev
Link to Webrev Comment