RVM
  1. RVM
  2. RVM-330

Thread.sleep() does not handle interrupts correctly

    Details

    • Testcase included:
      yes
    • Patch Submitted:
      Yes
    • Number of attachments :
      2

      Description

      Thread.sleep() fails to clear the interrupted status flag when it is interrupted. Furthermore, if the interrupt occurs before entering the sleep, the thread is left in an inconsistent state.

      The included patch fixes both problems.

      STATEMENT OF ORIGIN FOR A SINGLE CONTRIBUTOR
      I, Yuval Yarom:

      (a) represent that either:

      (i) I am the only author and owner of the contributed software
      (described as/entitled fixing runtime package isolation),
      which was neither derived nor copied from any other software,
      or

      (ii) that any exception to (i) is software which was obtained under the
      CPL (Common Public License),

      and

      (b) hereby agree to license this contributed software under the CPL.

      1. Sleep.diff
        0.8 kB
        Yuval Yarom
      2. Sleep.java
        0.3 kB
        Yuval Yarom

        Activity

        Hide
        David Grove added a comment -

        The fix seems plausible to me. Ian, you're the person who probably has the best grasp on the details of the thread system right now; any comments?

        Show
        David Grove added a comment - The fix seems plausible to me. Ian, you're the person who probably has the best grasp on the details of the thread system right now; any comments?
        Hide
        Ian Rogers added a comment -

        The patch looks good to me but we should test it with our existing core tests, we should also turn this test case into a core test. It may be interesting to see if this has any impact on the JSR 166 TCK, but not essential. The thread state changes are designed to fault unless we cleanly go between thread states. The thread state isn't actually used for anything. When introducing the notion of thread state (its new in 2.9.2) I was waiting for test cases to fail before fixing up the state transitions. This is why, for example, the code always tries to transition the state rather than just asserting that the state must now be runnable. My hope is it adds to the documentation and catches unexpected behaviour. I think to some extent its done this, but it clearly hasn't been perfect as Yuval's test case and fix demonstrate.

        Show
        Ian Rogers added a comment - The patch looks good to me but we should test it with our existing core tests, we should also turn this test case into a core test. It may be interesting to see if this has any impact on the JSR 166 TCK, but not essential. The thread state changes are designed to fault unless we cleanly go between thread states. The thread state isn't actually used for anything. When introducing the notion of thread state (its new in 2.9.2) I was waiting for test cases to fail before fixing up the state transitions. This is why, for example, the code always tries to transition the state rather than just asserting that the state must now be runnable. My hope is it adds to the documentation and catches unexpected behaviour. I think to some extent its done this, but it clearly hasn't been perfect as Yuval's test case and fix demonstrate.
        Hide
        Ian Rogers added a comment -

        Patch committed in r14086.

        Show
        Ian Rogers added a comment - Patch committed in r14086.

          People

          • Assignee:
            Ian Rogers
            Reporter:
            Yuval Yarom
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: