Harmony
  1. Harmony
  2. HARMONY-1722

notify() in synchronized section makes wait(long) wait forever

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DRLVM
    • Labels:
      None
    • Environment:
      Windows XP IA32
    • Estimated Complexity:
      Unknown

      Description

      DRLVM svn = r453182, (Oct 5 2006), Windows/ia32/msvc 1310, debug build
      with jit and interpreter (-Xint)

      The following test:

      public class Test {
      public static void main(String args[]) throws Exception {
      new Thread() {
      public void run() {
      while (true) {
      System.err.println("entering cycle");
      synchronized (this) {
      try

      { System.err.println("before wait"); wait(50); System.err.println("after wait"); notify(); }

      catch (InterruptedException e)

      { e.printStackTrace(); }

      }
      System.err.println("after cycle");
      }
      }
      }.start();
      }

      }

      Prints in RI:

      entering cycle
      before wait
      after wait
      after cycle
      entering cycle
      before wait
      after wait
      after cycle

      endlessly

      in DRL:

      entering cycle
      before wait
      after wait
      after cycle
      entering cycle
      before wait
      <test hangs>

      If we remove notify() from loop, the loop will become infinite

        Issue Links

          Activity

          Hide
          Anton Luht added a comment -

          can be closed - fixed with issue 1519

          Show
          Anton Luht added a comment - can be closed - fixed with issue 1519
          Hide
          Anton Luht added a comment -

          A bit more complicated test case still fails and causes JUnit test tests.java.lang.ThreadTest hang:

          public class Test {
          public static void main(String[] args) {
          final Object notify = new Object();

          Thread t1 = new Thread(new Runnable() {
          public void run() {
          synchronized (notify)

          { notify.notify(); }

          Thread.currentThread().suspend();
          }
          });
          System.err.println("mark 3");
          try {
          synchronized (notify)

          { t1.start(); notify.wait(); }

          // wait for Thread to suspend
          System.err.println("mark 4");
          Thread.sleep(500);
          System.err.println(t1.isAlive());
          System.err.println("mark 5");
          t1.resume();
          t1.join();
          System.err.println("mark 6");
          } catch (InterruptedException e) {
          }
          }

          }

          on RI and IBM VM it prints:

          mark 3
          mark 4
          true
          mark 5
          mark 6

          On DRL:
          mark 3
          mark 4
          <hangs>

          Show
          Anton Luht added a comment - A bit more complicated test case still fails and causes JUnit test tests.java.lang.ThreadTest hang: public class Test { public static void main(String[] args) { final Object notify = new Object(); Thread t1 = new Thread(new Runnable() { public void run() { synchronized (notify) { notify.notify(); } Thread.currentThread().suspend(); } }); System.err.println("mark 3"); try { synchronized (notify) { t1.start(); notify.wait(); } // wait for Thread to suspend System.err.println("mark 4"); Thread.sleep(500); System.err.println(t1.isAlive()); System.err.println("mark 5"); t1.resume(); t1.join(); System.err.println("mark 6"); } catch (InterruptedException e) { } } } on RI and IBM VM it prints: mark 3 mark 4 true mark 5 mark 6 On DRL: mark 3 mark 4 <hangs>
          Hide
          Alexei Fedotov added a comment -
          Show
          Alexei Fedotov added a comment - [drlvm] [unit] Blocks http://wiki.apache.org/harmony/Unit_Tests_Pass_on_DRLVM
          Hide
          Artem Aliev added a comment -

          Could not reproduce on the latest build.
          The issue looks like a duplicate of HARMONY-1741

          Just for fun:
          jrockit 1.5.0 output on linux:

          mark 3
          mark 4
          true
          mark 5
          <hangs>

          Show
          Artem Aliev added a comment - Could not reproduce on the latest build. The issue looks like a duplicate of HARMONY-1741 Just for fun: jrockit 1.5.0 output on linux: mark 3 mark 4 true mark 5 <hangs>
          Hide
          Alexei Fedotov added a comment -

          Couldn't reproduce on the latest build.

          Show
          Alexei Fedotov added a comment - Couldn't reproduce on the latest build.
          Hide
          Anton Luht added a comment -

          verified on

          svn = r471521, (Nov 5 2006), Windows/ia32/msvc 1310, debug build

          Show
          Anton Luht added a comment - verified on svn = r471521, (Nov 5 2006), Windows/ia32/msvc 1310, debug build
          Hide
          Alexey Petrenko added a comment -

          Reporter verified that this issue is not reproducible any more.

          Show
          Alexey Petrenko added a comment - Reporter verified that this issue is not reproducible any more.

            People

            • Assignee:
              Alexey Petrenko
              Reporter:
              Anton Luht
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development