Scala Programming Language
  1. Scala Programming Language
  2. SI-3838

Actor.receiveWithin may block indefinitely

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Library
    • Labels:
      None
    • Environment:

      Actor, Actors

      Description

      According to the documentation, receiveWithin should block at most msec milliseconds
      if no message matches any of the cases of the partial function passed as argument.

      This is not correct if the function is not defined on TIMEOUT and if the msec argument
      is > 0.

      The function

      def main(args: Array[String]){
      	Actor.receiveWithin(0) {
      		case str: String => println(str)
      	}
      }
      

      throws an "unhandled timeout" RuntimeException, however

      def main(args: Array[String]){
      	Actor.receiveWithin(1) {
      		case str: String => println(str)
      	}
      }
      

      blocks indefinitely. The TIMEOUT object is stored in the mailbox after the timeout, but it remains there as it is not consumed.
      Actually a new TIMEOUT object is added to the mailbox after each additional msec milliseconds.

      The function receiveWithin defines the local function receiveTimeout which checks, whether the function is defined at TIMEOUT, but this function is only called if msec == 0L.

      Dominik

        Activity

        Hide
        Paul Phillips added a comment -

        This sounds like a duplicate of SI-3799, but not sure: perhaps submitter could see if that sounds true and if so, close this as a duplicate.

        Show
        Paul Phillips added a comment - This sounds like a duplicate of SI-3799 , but not sure: perhaps submitter could see if that sounds true and if so, close this as a duplicate.
        Hide
        Dominik Gruntz added a comment -

        Replying to [comment:1 extempore]:
        > This sounds like a duplicate of SI-3799, but not sure:
        > perhaps submitter could see if that sounds true and if so,
        > close this as a duplicate.
        SI-3799 reports, that messages may be lost. In my example no message is lost, all messages remain in the actor's mailbox, but receiveWithin does not terminate after the timeout. Actually, the TIMEOUT message can be found in the mailbox. Note that this behavior changed from 2.7.7 to 2.8.0.

        => no duplicate.

        Show
        Dominik Gruntz added a comment - Replying to [comment:1 extempore] : > This sounds like a duplicate of SI-3799 , but not sure: > perhaps submitter could see if that sounds true and if so, > close this as a duplicate. SI-3799 reports, that messages may be lost. In my example no message is lost, all messages remain in the actor's mailbox, but receiveWithin does not terminate after the timeout. Actually, the TIMEOUT message can be found in the mailbox. Note that this behavior changed from 2.7.7 to 2.8.0. => no duplicate.
        Hide
        Philipp Haller added a comment -

        (In r24466) Closes SI-3838. Review by prokopec.

        Show
        Philipp Haller added a comment - (In r24466) Closes SI-3838 . Review by prokopec.

          People

          • Assignee:
            Philipp Haller
            Reporter:
            Dominik Gruntz
            TracCC:
            Erik Engbrecht, Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development