Skip to content
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

8289400: Improve com/sun/jdi/TestScaffold error reporting #10127

Closed

Conversation

plummercj
Copy link
Contributor

@plummercj plummercj commented Sep 1, 2022

com/sun/jdi tests report errors by calling TestScaffold.failure(msg), which prints the failure message and sets the testFailed flag. At some later point the failure is detected and an exception is thrown. The end result is the exception has just has a vanilla message that says something like "TestXXX failed", and the backtrace is not indicative of where the failure occurred. If you have tools that search logs looking for exceptions to determine the reason for the failure, you likely won't find any. Here's an example:

[2ms] run args: [SuspendAfterDeathTarg]
[514ms] FAILED: got Breakpoint event before ThreadDeath event.
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:432)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)

So the reason for the failure is clear (the "FAILED" message), but its stack trace is missing and the reason is not included in the exception message that is printed much later on. This PR adds printing of the stack trace at the time of the failure.

[2ms] run args: [SuspendAfterDeathTarg]
[514ms] FAILED: got Breakpoint event before ThreadDeath event.
        at TestScaffold.failure(TestScaffold.java:455)
        at SuspendAfterDeath.breakpointReached(SuspendAfterDeath.java:64)
        at TestScaffold$EventHandler.notifyEvent(TestScaffold.java:194)
        at TestScaffold$EventHandler.run(TestScaffold.java:278)
        at java.base/java.lang.Thread.run(Thread.java:1589) 
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:432)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8289400: Improve com/sun/jdi/TestScaffold error reporting

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10127/head:pull/10127
$ git checkout pull/10127

Update a local copy of the PR:
$ git checkout pull/10127
$ git pull https://git.openjdk.org/jdk pull/10127/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10127

View PR using the GUI difftool:
$ git pr show -t 10127

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10127.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 1, 2022

👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title 8289400 8289400: Improve com/sun/jdi/TestScaffold error reporting Sep 1, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 1, 2022
@openjdk
Copy link

openjdk bot commented Sep 1, 2022

@plummercj The following label will be automatically applied to this pull request:

  • serviceability

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.

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Sep 1, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 1, 2022

Webrevs

@@ -453,6 +453,9 @@ protected void traceln(String str) {

protected void failure(String str) {
println(str);
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
for (StackTraceElement traceElement : trace)

Choose a reason for hiding this comment

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

Please add curly braces around the cycle body

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. This was a copy-n-paste from Throwable.printStackTrace(), and I didn't noticed the omission when copying.

@openjdk
Copy link

openjdk bot commented Sep 1, 2022

@plummercj 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:

8289400: Improve com/sun/jdi/TestScaffold error reporting

Reviewed-by: amenkov, lmesnik

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 20 new commits pushed to the master branch:

  • 77e21c5: 8290529: C2: assert(BoolTest(btest).is_canonical()) failure
  • fcc0cf9: 8292375: Convert ProtectionDomainCacheTable to ResourceHashtable
  • 6fc58b8: 8293207: Add assert to JVM_ReferenceRefersTo to clarify its API
  • ce06a3b: 8293023: Change CardTable::is_in_young signature
  • 26cac08: 8293209: Parallel: Remove unused variables in PSParallelCompact::invoke
  • 46523b8: 8293219: Microsoft toolchain selection picks 32-bit tools over 64-bit
  • bc5ffc8: 8293100: RISC-V: Need to save and restore callee-saved FloatRegisters in StubGenerator::generate_call_stub
  • 98ce45f: 8292981: Unify and restructure integer printing format specifiers
  • 3ac91b0: 8293003: Review running time of Warn5 regression test
  • e0168a0: 8288012: AArch64: unnecessary macro expansion in stubGenerator_aarch64
  • ... and 10 more: https://git.openjdk.org/jdk/compare/07616de00c3e1c305852fcc44df8dadafd0dbf3f...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 1, 2022
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
for (StackTraceElement traceElement : trace) {
System.err.println("\tat " + traceElement);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thread.dumpStack() prints to System.errr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it does so by creating an Exception and calling printStackTrace() on it. I didn't want that because it includes the Exception itself in the output, not just the stack trace.

@plummercj
Copy link
Contributor Author

Thanks Alex and Leonid!

/integrate

@openjdk
Copy link

openjdk bot commented Sep 2, 2022

Going to push as commit da99e3e.
Since your change was applied there have been 20 commits pushed to the master branch:

  • 77e21c5: 8290529: C2: assert(BoolTest(btest).is_canonical()) failure
  • fcc0cf9: 8292375: Convert ProtectionDomainCacheTable to ResourceHashtable
  • 6fc58b8: 8293207: Add assert to JVM_ReferenceRefersTo to clarify its API
  • ce06a3b: 8293023: Change CardTable::is_in_young signature
  • 26cac08: 8293209: Parallel: Remove unused variables in PSParallelCompact::invoke
  • 46523b8: 8293219: Microsoft toolchain selection picks 32-bit tools over 64-bit
  • bc5ffc8: 8293100: RISC-V: Need to save and restore callee-saved FloatRegisters in StubGenerator::generate_call_stub
  • 98ce45f: 8292981: Unify and restructure integer printing format specifiers
  • 3ac91b0: 8293003: Review running time of Warn5 regression test
  • e0168a0: 8288012: AArch64: unnecessary macro expansion in stubGenerator_aarch64
  • ... and 10 more: https://git.openjdk.org/jdk/compare/07616de00c3e1c305852fcc44df8dadafd0dbf3f...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 2, 2022
@openjdk openjdk bot closed this Sep 2, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 2, 2022
@openjdk
Copy link

openjdk bot commented Sep 2, 2022

@plummercj Pushed as commit da99e3e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@plummercj plummercj deleted the 8289400_testscaffold_error_reporting branch October 11, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

4 participants