opened
francisdb
username_0
## steps

do a `test` run on the root of our project (aggregated)

## problem

sbt hangs during tests, until `ctrl-c` is pressed

## expectation

sbt shows test results

## notes

We have this on a specific machine (8-Core Intel Core i9).
Building on `1.3.7` works. With `1.3.8` the `test` command hangs forever (forked)

Not sure how to debug this though, thread dump of main and forked process attached
[thread_dumps.zip](https://github.com/sbt/sbt/files/4214682/thread_dumps.zip)

ctrl-c output (last)

```
[warn] Canceling execution...
[debug] Forcing garbage collection...
[error] java.util.concurrent.ExecutionException: Incomplete(node=None, tpe=Error, msg=Some(cancelled), causes=List(), directCause=None)
[error] 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
[error] 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.take(ConcurrentRestrictions.scala:213)
[error] 	at sbt.Execute.next$1(Execute.scala:116)
[error] 	at sbt.Execute.processAll(Execute.scala:126)
[error] 	at sbt.Execute.runKeep(Execute.scala:94)
[error] 	at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:477)
[error] 	at sbt.EvaluateTask$.run$1(EvaluateTask.scala:476)
[error] 	at sbt.EvaluateTask$.runTask(EvaluateTask.scala:497)
[error] 	at sbt.internal.Aggregation$.$anonfun$timedRun$4(Aggregation.scala:101)
[error] 	at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:400)
[error] 	at sbt.internal.Aggregation$.timedRun(Aggregation.scala:99)
[error] 	at sbt.internal.Aggregation$.runTasks(Aggregation.scala:113)
[error] 	at sbt.internal.Aggregation$.$anonfun$applyTasks$1(Aggregation.scala:68)
[error] 	at sbt.Command$.$anonfun$applyEffect$2(Command.scala:144)
[error] 	at sbt.internal.Aggregation$.$anonfun$evaluatingParser$11(Aggregation.scala:227)
[error] 	at sbt.internal.Act$.$anonfun$actParser0$4(Act.scala:436)
[error] 	at sbt.Command$.process(Command.scala:187)
[error] 	at sbt.MainLoop$.process$1(MainLoop.scala:193)
[error] 	at sbt.MainLoop$.processCommand(MainLoop.scala:227)
[error] 	at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:142)
[error] 	at sbt.State$StateOpsImpl$.runCmd$1(State.scala:273)
[error] 	at sbt.State$StateOpsImpl$.process$extension(State.scala:277)
[error] 	at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:142)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] 	at sbt.MainLoop$.next(MainLoop.scala:142)
[error] 	at sbt.MainLoop$.run(MainLoop.scala:133)
[error] 	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:111)
[error] 	at sbt.io.Using.apply(Using.scala:27)
[error] 	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:105)
[error] 	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:60)
[error] 	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:45)
[error] 	at sbt.MainLoop$.runLogged(MainLoop.scala:36)
[error] 	at sbt.StandardMain$.runManaged(Main.scala:132)
[error] 	at sbt.xMain$.run(Main.scala:67)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] 	at sbt.internal.XMainConfiguration.run(XMainConfiguration.scala:45)
[error] 	at sbt.xMain.run(Main.scala:39)
[error] 	at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
[error] 	at xsbt.boot.Launch$.withContextLoader(Launch.scala:130)
[error] 	at xsbt.boot.Launch$.run(Launch.scala:111)
[error] 	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
[error] 	at xsbt.boot.Launch$.launch(Launch.scala:119)
[error] 	at xsbt.boot.Launch$.apply(Launch.scala:20)
[error] 	at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error] 	at xsbt.boot.Boot$.main(Boot.scala:18)
[error] 	at xsbt.boot.Boot.main(Boot.scala)
[error] Caused by: Incomplete(node=None, tpe=Error, msg=Some(cancelled), causes=List(), directCause=None)
[error] 	at sbt.CompletionService$.submit(CompletionService.scala:38)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.submitValid(ConcurrentRestrictions.scala:180)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.submitValid(ConcurrentRestrictions.scala:207)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.cleanup(ConcurrentRestrictions.scala:189)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:179)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:834)
[error] java.util.concurrent.ExecutionException: Incomplete(node=None, tpe=Error, msg=Some(cancelled), causes=List(), directCause=None)
[error] Use 'last' for the full log.
[debug] > Exec(shell, None, None)
[debug] Evaluating tasks: checkBuildSources
[debug] Running task... Cancel: Signal, check cycles: false, forcegc: true
```
Build hangs on 1.3.8
issue
created
eed3si9n
username_1
@username_0 Thanks for the report. How many tests do you see on super shell when this happens?
comment
created
francisdb
username_0
This is where it locks up

```
 | => a / Test / compile / compilerReporter 0s
  | => a / testListeners 0s
  | => b / testListeners 0s
  | => c / testListeners 0s
  | => d / testListeners 0s
  | => e / testListeners 0s
  | => f / testListeners 0s
  | => g / testListeners 0s
  | => h / testListeners 0s
  | => i / testListeners 0s
  | => j / testListeners 0s
  | => k / testListeners 0s
  | => l / testListeners 0s
  | => m / testListeners 0s
  | => n / testListeners 0s
  | => o / testListeners 0s
```
comment
created
eed3si9n
username_1
Looking at https://github.com/sbt/sbt/releases/tag/v1.3.8, https://github.com/sbt/zinc/pull/731 might be the closest related change?
comment
created
francisdb
username_0
Might be safer to use an AtomicReference?
comment
created
eed3si9n
username_1
@username_0 If you could send a PR for it, I can trigger a nightly process we can use to test the theory.
comment
created
francisdb
username_0
Just had another lockup

```
  | => a / scalaCompilerBridgeScope / dependencyResolution 0s
  | => b / Test / unmanagedSources / inputFileStamps 0s
  | => c / Test / unmanagedSources / inputFileStamps 0s
  | => c / Compile / unmanagedSources / inputFileStamps 0s
  | => d / Compile / unmanagedSources / inputFileStamps 0s
```

(a, b, ... not corresponding to above example)
comment
created
francisdb
username_0
@username_1 ping
comment
created
eed3si9n
username_1
I kicked off a nightly build using the branch.
comment
created
francisdb
username_0
Please let me know how I can test it once it's done
comment
closed
francisdb
username_0
issue
created
francisdb
username_0
I'm going to close this issue for now as I seem to have a similar issue on sbt `1.3.7` which indicates that it must be related to my own code
Also nobody else seems to be seeing this.
Might re-open this once I get this debugged. Sorry for wasting your time @username_1
comment
created
francisdb
username_0
Note for future self: we fixed this by rewriting a test from `Specs2` to `ScalaTest` but that might just have moved a threading issue to an other place/time.
(strangely that test was not doing anything async / threading / blocking)
comment