Skip to content

Commit

Permalink
Fix deadlock in t5375 and similar tests.
Browse files Browse the repository at this point in the history
See t5375.scala for details.
  • Loading branch information
DarkDimius committed May 26, 2016
1 parent f85663a commit 4007910
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
// though the second condition seems weird, it's not true for symbols which are defined in some
// weird combinations of super calls.
(encClass, EmptyFlags)
} else
(topClass, JavaStatic)
} else if (encClass.is(ModuleClass, butNot = Package) && encClass.isStatic) // needed to not cause deadlocks in classloader. see t5375.scala
(encClass, EmptyFlags)
else (topClass, JavaStatic)
}
else (lOwner, EmptyFlags)
local.copySymDenotation(
Expand Down
11 changes: 11 additions & 0 deletions tests/run/t5375.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/** Hello fellow compiler developer.
if you are wondering why does test suite hang on this test
then it's likely that the lambda inside map has been compiled into static method
unfotrunatelly, as it is executed inside static object initializer,
it is executed inside class-loader, in a synchronized block that is not source defined.
If the lambda will be static Test$#foo, calling it through a different thread would require grabbing the
lock inside classloader. Unlike if it not static and is called through This(Test).foo, no lock is grabbed.
@DarkDimius
*/
object Test extends dotty.runtime.LegacyApp {
val foos = (1 to 1000).toSeq
try
Expand Down

0 comments on commit 4007910

Please sign in to comment.