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
8271471: [IR Framework] Rare occurrence of "<!-- safepoint while printing -->" in PrintIdeal/PrintOptoAssembly can let tests fail #4932
Conversation
…ting -->" in PrintIdeal/PrintOptoAssembly can let tests fai
|
@chhagedorn The following label 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 list. If you would like to change these labels, use the /label pull request command. |
/label add hotspot-compiler |
@chhagedorn |
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.
Agree.
@chhagedorn This change now passes all automated pre-integration checks. 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 65 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.
|
I think the expectation is that a safepoint whilst printing and holding the tty lock should be a very rare thing, possibly indicative of an error, and so something we want to know about. If this is hidden by Verbose then it will effectively always be hidden and we won't spot this. Do you understand why this is getting printed in this context, and that it doesn't indicate a problem? Thanks, |
I see your concern. Let me try to reproduce it and get some more information when it happens again. This might take some time. I'll get back to you. |
I played around with it and interestingly this code path is hit quite often when just running I had a closer look at one of these occurrences. In this case, the reason we are executing jdk/src/hotspot/share/opto/output.cpp Lines 1870 to 1871 in eec64f5
or at jdk/src/hotspot/share/opto/compile.cpp Lines 789 to 790 in eec64f5
Therefore, we break the lock inside ThreadInVMfromNative() at the next print call in the C2 compiler thread because SafepointMechanism::local_poll_armed() is true.
To me this seems okay and not a problem but just bad luck due to timing. |
Thanks @chhagedorn . I can see that this message is somewhat expected in this context. Is it really that difficult to ignore in the IR matching? This is XML-ouput and it is formatted as a comment, so shouldn't the matching logic ignore XML comments? |
I can think of a few options:
In terms of performance, it is probably best to bail out and do a one time effort to make the internal framework tests aware of this bailout scenario (option 1). While thinking about it for a second time, it might not be that complicated as I thought before. My original idea was just to first propose a removal of this tty message before going into fixing this rare case. But of course, given that there are concerns, I'm considering one of these options (my favorite is option 1). |
I would also go with option 1). For the framework internal tests that expect and exception, couldn't you simply add something like a |
…ests to handle it (option 1)
Thanks Tobias, I therefore went with option 1 and reverted the HotSpot change. The problem is when no |
import compiler.lib.ir_framework.driver.TestVMProcess; | ||
|
||
public class Utils { | ||
public static void shouldHaveCaughtException() { |
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.
Should these methods be renamed to shouldHaveThrownException
? Because that method could also be used in a context where we don't catch.
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.
Agreed, that's a better name!
if (!hitSafePointWhilePrinting) { | ||
throw new ShouldHaveCaughtException(); | ||
} | ||
} |
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.
Why don't we simply do:
for (Scenario s : scenarios) {
shouldHaveCaughtException(s.getTestVMOutput());
}
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 that code, see comment below.
I did a renaming and changed the way |
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. I'm just wondering if we need all that notAllBailedOut
/noneBailedOut
complexity for handling scenarios. Given that safepoints during printing are rare, couldn't we simply skip verification of the exception message if one scenario hit a bailout?
return !Arrays.stream(scenarios).allMatch(s -> s.getTestVMOutput().contains(IRMatcher.SAFEPOINT_WHILE_PRINTING_MESSAGE)); | ||
} | ||
|
||
private static void shouldHaveThrownException(String testVMOutput) { |
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.
Now this method is only used by shouldHaveThrownException()
. I would remove it.
// Not all scenarios had a bailout which means that at least one exception should have been thrown. | ||
Asserts.fail("Should have thrown an exception"); | ||
} | ||
|
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.
Newline can be removed
I think we need the
Yes, that's probably easier. We can also first check if the expected message was even mismatched in But yes, I agree that it's some complexity for a rather rare case. I pushed an updated with these changes. |
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, thanks for making these changes!
Thank you Tobias for your careful review! |
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.
Good
Thanks Vladimir for your review! |
/integrate |
Going to push as commit 3677734.
Your commit was automatically rebased without conflicts. |
@chhagedorn Pushed as commit 3677734. |
A test VM used by the IR framework sometimes prints
<!-- safepoint while printing -->
in the middle of emitting aPrintIdeal
orPrintOptoAssembly
output which could lead to IR matching failures:jdk/src/hotspot/share/utilities/ostream.cpp
Lines 918 to 927 in 489e5fd
I thought about just bailing out of IR matching if this string is found after a failure but this issue also affects internal framework tests (I observed one case locally where this happened in the test
TestIRMatching
, letting it fail).Handling
<!-- safepoint while printing -->
makes things more complicated for the IR framework tests. I'm not sure about the value of printing this message in the first place. But if nobody objects, I suggest to either remove it or at least guard it withVerbose
, for example. I went with the latter solution in this PR.Thanks,
Christian
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4932/head:pull/4932
$ git checkout pull/4932
Update a local copy of the PR:
$ git checkout pull/4932
$ git pull https://git.openjdk.java.net/jdk pull/4932/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4932
View PR using the GUI difftool:
$ git pr show -t 4932
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4932.diff