question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Working on minimizing this. Still a ways to go but I’m getting much closer. Please see this branch: https://github.com/djspiewak/cats-effect/tree/bug/dotty-compiler-oom You can reproduce the OOM by running sbt ++3.0.0-M3 kernelJVM/clean kernelJVM/compile (ignore the errors; that code could just be deleted but I haven’t done it yet).

The offending call site appears to be this one: https://github.com/djspiewak/cats-effect/blob/bug/dotty-compiler-oom/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala#L33 If you uncomment the explicit type parameters, it compiles reasonably quickly. Forcing the compiler to make this inference for us (which 2.13 does just fine) causes it to spin its wheels for about a minute (on my laptop) before running out of memory.

Note that the import Resource._ and the implicit in the companion object are also necessary. I haven’t minimized the other imports, but I suspect most of them are unneeded.

In case it’s helpful, I coaxed this stack trace out of it:

java.lang.OutOfMemoryError: GC overhead limit exceeded
  at scala.collection.immutable.List.$colon$colon(List.scala:97)
  at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5070)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5102)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5080)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5105)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.op$proxy13$1(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5102)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5080)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5105)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.op$proxy13$1(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5102)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5080)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5105)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)
  at dotty.tools.dotc.core.Types$TypeMap.op$proxy13$1(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5067)
  at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5102)
  at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:145)
  at dotty.tools.dotc.core.Substituters$SubstParamMap.apply(Substituters.scala:193)

This reproduces against both M2 and M3.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
oderskycommented, Jan 3, 2021

I found the cause. It was a rather stupid mistake where we compared the wrong symbols. But all the real work was done by @griggt here.

1reaction
griggtcommented, Jan 1, 2021

It’s probably not fully minimized, but this self-contained example seems to trigger the issue:

trait Monoid[A]
trait Semigroup[A]
trait Applicative[F[_]]

trait OptionT[F[_], A]
trait EitherT[F[_], A, B]
trait IorT[F[_], A, B]
trait WriterT[F[_], L, V]
trait Kleisli[F[_], A, B]

final class ApplicativeIdOps[A](private val a: A) extends AnyVal {
  def pure[F[_]](implicit F: Applicative[F]): F[A] = ???
}

object ApplicativeSyntax {
  implicit final def syntaxApplicativeId[A](a: A): ApplicativeIdOps[A] = new ApplicativeIdOps[A](a)
}

trait Sync[F[_]]

object Sync {
  implicit def syncForOptionT[F[_]](implicit F0: Sync[F]): Sync[OptionT[F, *]] = ???
  implicit def syncForEitherT[F[_], E](implicit F0: Sync[F]): Sync[EitherT[F, E, *]] = ???
  implicit def syncForIorT[F[_], L](implicit F0: Sync[F], L0: Semigroup[L]): Sync[IorT[F, L, *]] = ???
  implicit def syncForWriterT[F[_], L](implicit F0: Sync[F], L0: Monoid[L]): Sync[WriterT[F, L, *]] = ???
  implicit def syncForKleisli[F[_], R](implicit F0: Sync[F]): Sync[Kleisli[F, R, *]] = ???
}

trait Async[F[_]] extends Sync[F]

object Async {
  implicit def asyncForOptionT[F[_]](implicit F0: Async[F]): Async[OptionT[F, *]] = ???
  implicit def asyncForEitherT[F[_], E](implicit F0: Async[F]): Async[EitherT[F, E, *]] = ???
  implicit def asyncForIorT[F[_], L](implicit F0: Async[F], L0: Semigroup[L]): Async[IorT[F, L, *]] = ???
  implicit def asyncForWriterT[F[_], L](implicit F0: Async[F], L0: Monoid[L]): Async[WriterT[F, L, *]] = ???
  implicit def asyncForKleisli[F[_], R](implicit F0: Async[F]): Async[Kleisli[F, R, *]] = ???
}

trait Concurrent[F[_], E] extends Applicative[F]

trait Ref[F[_], A]

object Ref {
  trait Make[F[_]]
  object Make extends MakeInstances

  trait MakeInstances extends MakeLowPriorityInstances {
    implicit def concurrentInstance[F[_]](implicit F: Concurrent[F, _]): Make[F] = ???
  }

  trait MakeLowPriorityInstances {
    implicit def syncInstance[F[_]](implicit F: Sync[F]): Make[F] = ???
  }

  def of[F[_], A](a: A)(implicit mk: Make[F]): F[Ref[F, A]] = ???
}


class Resource[F[_], A] {
  import ApplicativeSyntax._

  implicit def asyncForResource[F[_]](implicit F0: Async[F]): Async[Resource[F, *]] = ???

  def parZip(implicit F: Concurrent[F, Throwable]) = {
    Ref.of /*[F, (F[Unit], F[Unit])]*/ (().pure[F] -> ().pure[F])
    ()
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Adjusting your video layout during a virtual meeting
Customize your video layout preferences during your Zoom meetings—see everyone, hide participants, and much more.
Read more >
Zoom: Changing video layouts - Article
Minimized Zoom window. If you minimize your Zoom window to access other programs on your computer, your Zoom meeting will show in a...
Read more >
Causes of and solutions to the issue of OOM Killer being ...
OOM Killer is triggered when the global memory of an instance or the memory of a cgroup in an instance is insufficient. The...
Read more >
libFuzzer minimizer needs to do basic stack comparison #452
This fails on several targets which get engulfed with timeouts or other crash types. It is important to compare crash type and minimal...
Read more >
Installing perf on Ubuntu 20.04 LTS in Oracle Cloud ...
This is a very short post with instructions on how to install perf on Ubunutu 20.04 LTS in Oracle Cloud Infrastructure (OCI).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found