Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277659

[TESTBUG] Microbenchmark ThreadOnSpinWaitProducerConsumer.java hangs

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • None
    • 18
    • hotspot
    • None
    • b26
    • generic
    • generic

    Description

      The microbenchmark "test/micro/org/openjdk/bench/java/lang/ThreadOnSpinWaitProducerConsumer.java" runs with a producer and a consumer thread interacting with one another through two shared variables.
      When the benchmark run has complete, the producer thread exists once a counter exceeds a given number. The consumer thread exits after it has been interrupted. The thread executing the trial method that coordinates this called "Thread.join" on the producer thread before calling "Thread.interrupt" on the consumer thread and then exiting.
      The harness will create new producer and consumer threads. However, the consumer thread may still be executing as the "trial" method doesn't wait for the consumer thread to exit. This can consume values from the producer and exit, leaving the other consumer thread waiting indefinitely.

      My suggested solution is for the "trial" method to call "Thread.join" against the consumer thread. This prevents the test from restarting with two active consumer threads.

      This happens on x86 and aarch64 Linux. With the correct timing, I expect any platform would be affected.

      Attachments

        Issue Links

          Activity

            People

              smonteith Stuart Monteith
              smonteith Stuart Monteith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: