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

Deadlock when parallel collection function throws an exception

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1
    • Fix Version/s: Scala 2.10.0-M1
    • Component/s: Collections
    • Labels:
      None
    • Environment:

      Scala 2.9.1, Oracle JDK 1.7.0u2

      Description

      When doing a map over a parallel sequence, my program deadlocks waiting on the result if the map function threw an exception. Test case (exhibits problem in Scala 2.9.1 REPL on Oracle JDK 1.7.0u2, Linux x86_64):

      val foos = (1 to 1000) toSeq
      foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i).seq
      

      Entering this code in the toplevel will result in an indefinite hang. jstack reveals that all interesting threads are waiting, either on object monitors or parked.

        Activity

        Hide
        Paul Phillips added a comment -

        For the record, I only can reproduce that deadlock with scala 2.9.1 on java7. If I use either scala trunk or java6, the exception comes out. So this appears fixed in trunk.

        Show
        Paul Phillips added a comment - For the record, I only can reproduce that deadlock with scala 2.9.1 on java7. If I use either scala trunk or java6, the exception comes out. So this appears fixed in trunk.
        Hide
        Michael Ekstrand added a comment -

        I have downloaded the latest nightlies for 2.9.2 and 2.10.0 and tried it. It works correctly on 2.10 but deadlocks on 2.9.2.

        It also works on 2.9.1 on OpenDK6 on my machine.

        Show
        Michael Ekstrand added a comment - I have downloaded the latest nightlies for 2.9.2 and 2.10.0 and tried it. It works correctly on 2.10 but deadlocks on 2.9.2. It also works on 2.9.1 on OpenDK6 on my machine.
        Hide
        Aleksandar Prokopec added a comment -

        The reason it didn't work on java7 is that the vendor name changed to "Oracle", so the fork join pool wasn't used. This was already fixed in trunk, but wasn't backported to 2.9.2.
        This bug was still happening on java5, but I've fixed it now.

        Show
        Aleksandar Prokopec added a comment - The reason it didn't work on java7 is that the vendor name changed to "Oracle", so the fork join pool wasn't used. This was already fixed in trunk, but wasn't backported to 2.9.2. This bug was still happening on java5, but I've fixed it now.
        Hide
        Heikki Vesalainen added a comment -

        2.9.3 RC1 is out. Could the original fix developer backport this to 2.9.3 or should I take a stab at it?

        Show
        Heikki Vesalainen added a comment - 2.9.3 RC1 is out. Could the original fix developer backport this to 2.9.3 or should I take a stab at it?
        Hide
        Jason Zaugg added a comment -

        The ForkJoin detection was already added to 2.9.2.

        2.9.x ~/code/scala2 git show 9eb9682f792e26bf99e74e777b776d5ce841a595
        commit 9eb9682f792e26bf99e74e777b776d5ce841a595
        Author: Aleksandar Pokopec <aleksandar.prokopec@epfl.ch>
        Date:   Fri Nov 11 16:59:45 2011 +0000
        
            Changes the fork join pool detection for JVM1.7...
            
            Changes the fork join pool detection for JVM1.7, for actors and parallel
            collections libraries.
            
            Review by phaller.
        
        diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/acto
        index d514d94..a7bf8ec 100644
        --- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
        +++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
        @@ -45,7 +45,7 @@ private[actors] object ThreadPoolConfig {
         
                 // on IBM J9 1.6 do not use ForkJoinPool
                 // XXX this all needs to go into Properties.
        -        isJavaAtLeast("1.6") && ((javaVmVendor contains "Sun") || (javaVmVendor
        +        isJavaAtLeast("1.6") && ((javaVmVendor contains "Oracle") || (javaVmVen
               })
             catch {
               case _: SecurityException => false
        2.9.x ~/code/scala2 git tag --contains 9eb9682f792e26bf99e74e777b776d5ce841a595
        v2.9.2
        v2.9.2-RC2
        v2.9.2-RC3
        v2.9.3-RC1
        
        Show
        Jason Zaugg added a comment - The ForkJoin detection was already added to 2.9.2. 2.9.x ~/code/scala2 git show 9eb9682f792e26bf99e74e777b776d5ce841a595 commit 9eb9682f792e26bf99e74e777b776d5ce841a595 Author: Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> Date: Fri Nov 11 16:59:45 2011 +0000 Changes the fork join pool detection for JVM1.7... Changes the fork join pool detection for JVM1.7, for actors and parallel collections libraries. Review by phaller. diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/acto index d514d94..a7bf8ec 100644 --- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala +++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala @@ -45,7 +45,7 @@ private[actors] object ThreadPoolConfig { // on IBM J9 1.6 do not use ForkJoinPool // XXX this all needs to go into Properties. - isJavaAtLeast("1.6") && ((javaVmVendor contains "Sun") || (javaVmVendor + isJavaAtLeast("1.6") && ((javaVmVendor contains "Oracle") || (javaVmVen }) catch { case _: SecurityException => false 2.9.x ~/code/scala2 git tag --contains 9eb9682f792e26bf99e74e777b776d5ce841a595 v2.9.2 v2.9.2-RC2 v2.9.2-RC3 v2.9.3-RC1

          People

          • Assignee:
            Aleksandar Prokopec
            Reporter:
            Michael Ekstrand
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development