Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SI-9076 SAM in REPL gives non-termination of Java 8 Stream #195

Closed
adriaanm opened this issue Aug 4, 2016 · 8 comments
Closed

SI-9076 SAM in REPL gives non-termination of Java 8 Stream #195

adriaanm opened this issue Aug 4, 2016 · 8 comments
Assignees
Milestone

Comments

@adriaanm
Copy link
Contributor

adriaanm commented Aug 4, 2016

@DarkDimius said:

As far as I understand the reason, I've fixed in in dotty by making lambdas inside static modules be non static and refer to module itself through this. scala/scala3@3b0cb48

@adriaanm adriaanm added this to the 2.12.0-RC1 milestone Aug 4, 2016
@adriaanm adriaanm changed the title lambda in static module should non-static for proper locking SI-9076 lambda in static module should non-static for proper locking Aug 12, 2016
@adriaanm adriaanm changed the title SI-9076 lambda in static module should non-static for proper locking SI-9076 SAM in REPL gives non-termination of Java 8 Stream Sep 6, 2016
@adriaanm
Copy link
Contributor Author

adriaanm commented Sep 6, 2016

We could also fix this by changing the encoding in the REPL to be like the currently experimental class-based encoding. This has a workaround as well, so not a release blocker.

@adriaanm adriaanm modified the milestones: 2.12.x, 2.12.0-RC1 Sep 6, 2016
@adriaanm adriaanm modified the milestones: 2.13.0-M2, 2.12.x Apr 21, 2017
@adriaanm adriaanm self-assigned this Apr 21, 2017
@adriaanm
Copy link
Contributor Author

See also the analysis at typelevel/scalacheck#290 (comment)

@SethTisue
Copy link
Member

SethTisue commented Jun 3, 2017

There are a lot of tickets in this area. Besides, scala/bug#9076, there's scala/bug#8119 and scala/bug#9824.

(I personally am not sure, without going back over it, how many "different" issues there actually are here.)

@SethTisue
Copy link
Member

the best minimal reproducer I know that is 2.12-specific is:

for (i <- (1 to 100).par) yield i

this hangs the 2.12 REPL but not the 2.11 REPL

@adriaanm
Copy link
Contributor Author

I think it makes more sense to tackle this in 2.14.

@olafurpg
Copy link
Member

olafurpg commented Jan 1, 2019

Regular programs are also affected, here's a repro that crashes outside the REPL

object Boom {
  import scala.concurrent._, duration._, ExecutionContext.Implicits.global
  val x = Await.result(Future(1), Duration("1s"))
}

The following program does not crash.

import scala.concurrent._, duration._, ExecutionContext.Implicits.global
object Boom {
  val x = Future(1)
}
object Ok {
  val x = Await.result(Boom.x, Duration("1s"))
}

Workaround is to enable -Ydelambdafy:inline.

smarter added a commit to smarter/dotty that referenced this issue Jan 25, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Jan 25, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Jan 25, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Jan 25, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Jan 26, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Jan 26, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to smarter/dotty that referenced this issue Feb 2, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 3, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

For some reason, this commit causes the issue described in scala#3383 to
reappear, we add a workaround for that in Trees.scala.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 3, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

For some reason, this commit causes the issue described in scala#3383 to
reappear, we add a workaround for that in Trees.scala.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 3, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

This commit causes a cyclic reference to happen in some cases, we add a
workaround to avoid this in Trees.scala and fix it properly in the
commit.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 6, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

This commit causes a cyclic reference to happen in some cases, we add a
workaround to avoid this in Trees.scala and fix it properly in the
commit.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 6, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

This commit causes a cyclic reference to happen in some cases, we add a
workaround to avoid this in Trees.scala and fix it properly in the
commit.
eed3si9n pushed a commit to eed3si9n/scala that referenced this issue May 14, 2019
To avoid deadlocks when combining objects, lambdas and multi-threading,
lambdas in objects are compiled to instance methods of the module class
instead of static methods (see tests/run/deadlock.scala and
scala/scala-dev#195 for details).

This has worked well for us so far but this is problematic for
serialization: serializing a lambda requires serializing all the values
it captures, if this lambda is in an object, this means serializing the
enclosing object, which fails if the object does not extend
Serializable.

Because serializing objects is basically free since scala#5775, it seems like
the simplest solution is to simply make all objects Serializable, this
certainly seems preferable to deadlocks.

This commit causes a cyclic reference to happen in some cases, we add a
workaround to avoid this in Trees.scala and fix it properly in the
commit.
@lrytz lrytz modified the milestones: 2.14, 2.13.2 Feb 25, 2020
@lrytz
Copy link
Member

lrytz commented Feb 25, 2020

scala/scala#8748

@lrytz lrytz closed this as completed Feb 25, 2020
@SethTisue
Copy link
Member

🍾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants