From 5709485cf32c03160c706b1dfa3fd16dc42e94e0 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 19 Apr 2017 11:07:47 -0500 Subject: [PATCH 1/2] Fix the infinite cycle in Lazy Vlas Reported by Andrzej Plutecki in https://groups.google.com/forum/#!topic/dotty-internals/3LMNItLQw-A I haven't seen this happen in practice in hours and hours of benchmarking, but this is indeed a formal bug. --- library/src/dotty/runtime/LazyVals.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/src/dotty/runtime/LazyVals.scala b/library/src/dotty/runtime/LazyVals.scala index 2c06a5dd8f05..97626c48e1b2 100644 --- a/library/src/dotty/runtime/LazyVals.scala +++ b/library/src/dotty/runtime/LazyVals.scala @@ -67,7 +67,8 @@ object LazyVals { else if (state == 2) { val monitor = getMonitor(t, ord) monitor.synchronized { - monitor.wait() + if (STATE(cur, ord) == 2) + monitor.wait() } } else retry = false From 2f78dac234bbe48352a1cb693b7f88ac6f928f85 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 19 Apr 2017 11:32:20 -0500 Subject: [PATCH 2/2] Fix the fix Long time since I wrote this code. Forgot that `State` doesn't read the state. --- library/src/dotty/runtime/LazyVals.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/dotty/runtime/LazyVals.scala b/library/src/dotty/runtime/LazyVals.scala index 97626c48e1b2..b2240c86036d 100644 --- a/library/src/dotty/runtime/LazyVals.scala +++ b/library/src/dotty/runtime/LazyVals.scala @@ -67,7 +67,7 @@ object LazyVals { else if (state == 2) { val monitor = getMonitor(t, ord) monitor.synchronized { - if (STATE(cur, ord) == 2) + if (STATE(get(t, offset), ord) == 2) // make sure notification did not happen yet. monitor.wait() } }