typelevel / typelevel/scalacheck

Properties("") tests are suffering of deadlock to static scala initializers

Open
#155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2k
Forks
393
Avg merge
6h 42m
Merged PRs (30d)
4

Description

Current version of Scalacheck when using the Properties("") helper is suffering from deadlock as documented in https://issues.scala-lang.org/browse/SI-7646 or http://stackoverflow.com/questions/15176199/scala-parallel-collection-in-object-initializer-causes-a-program-to-hang

It seems that making the tests to extends DelayedInit (deprecated) is resolving the issue. That means in other words if Properties will extend the App trait it is reasonable workaround. However that makes the Spec invisible to sbt.

Would be nice if Properties will be extending the App and be still visible to sbt.

There is a simple workaround using DelayedInit that can be used for now, before DelayedInit is removed:

class DProperties(name:String)  extends Properties(name) with DelayedInit {

  var init: Option[() ⇒ Unit] = None

  override def delayedInit(x: ⇒ Unit): Unit = init = Some(() ⇒ x)

  override def main(args: Array[String]) = {
    init.foreach(_())
    super.main(args)
  }

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Properties("") helper and reproduce the static-initializer deadlock described in the linked reports. Investigate the DelayedInit workaround and the interaction with sbt discovery; done means the helper avoids the deadlock while the Spec remains visible to sbt.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.