Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError in pattern analysis #8999

Closed
scabug opened this issue Nov 21, 2014 · 9 comments
Closed

OutOfMemoryError in pattern analysis #8999

scabug opened this issue Nov 21, 2014 · 9 comments

Comments

@scabug
Copy link

scabug commented Nov 21, 2014

When compiling the Scala.js linker (aka the tools), the pattern matcher analysis runs out of memory:

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
    at scala.collection.immutable.HashMap$HashTrieMap.updated0(HashMap.scala:330)
    at scala.collection.immutable.HashMap$HashTrieMap.updated0(HashMap.scala:322)
    at scala.collection.immutable.HashMap.$plus(HashMap.scala:60)
    at scala.collection.immutable.HashMap.$plus(HashMap.scala:37)
    at scala.tools.nsc.transform.patmat.Solving$Solver$$anonfun$expandUnassigned$1$1$$anonfun$apply$2.force$1(Solving.scala:178)
    at scala.tools.nsc.transform.patmat.Solving$Solver$$anonfun$expandUnassigned$1$1$$anonfun$apply$2.apply(Solving.scala:180)
    at scala.tools.nsc.transform.patmat.Solving$Solver$$anonfun$expandUnassigned$1$1$$anonfun$apply$2.apply(Solving.scala:176)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at scala.tools.nsc.transform.patmat.Solving$Solver$class.expandUnassigned$1(Solving.scala:173)
    at scala.tools.nsc.transform.patmat.Solving$Solver$class.findAllModels$1(Solving.scala:209)
    at scala.tools.nsc.transform.patmat.Solving$Solver$class.findAllModelsFor(Solving.scala:217)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.findAllModelsFor(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.findAllModelsFor(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.MatchAnalysis$MatchAnalyzer$class.exhaustive(MatchAnalysis.scala:523)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.exhaustive(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.MatchAnalysis$MatchAnalyzer$class.analyzeCases(MatchAnalysis.scala:783)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.analyzeCases(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.MatchTreeMaking$TreeMakers$class.combineCasesNoSubstOnly(MatchTreeMaking.scala:576)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.combineCasesNoSubstOnly(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.MatchTreeMaking$TreeMakers$class.combineCases(MatchTreeMaking.scala:533)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.combineCases(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.MatchTranslation$MatchTranslator$class.translateMatch(MatchTranslation.scala:235)
    at scala.tools.nsc.transform.patmat.PatternMatching$OptimizingMatchTranslator.translateMatch(PatternMatching.scala:89)
    at scala.tools.nsc.transform.patmat.PatternMatching$MatchTransformer.transform(PatternMatching.scala:62)
    at scala.tools.nsc.transform.patmat.PatternMatching$MatchTransformer.transform(PatternMatching.scala:57)
    at scala.reflect.internal.Trees$$anonfun$itransform$1.apply(Trees.scala:1350)
    at scala.reflect.internal.Trees$$anonfun$itransform$1.apply(Trees.scala:1349)
    at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2600)
    at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:30)
    at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:25)
    at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:17)
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded

To reproduce (if it works on your machine), checkout Scala.js and issue sbt ++2.11.4 tools/compile or alternatively sbt ++2.11.4 partest/compile.

Originated in scala-js/scala-js#1204.

@scabug
Copy link
Author

scabug commented Nov 21, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8999?orig=1
Reporter: @gzm0
Affected Versions: 2.11.4

@scabug
Copy link
Author

scabug commented Nov 24, 2014

@retronym said:
PIng @gbasler Have you got a patch and/or standalone test for this one in the works? I'd like to address the regression in 2.11.5 which is coming up in a month or so.

@scabug
Copy link
Author

scabug commented Dec 2, 2014

@gbasler said:
I'm still working on it but I think I am close (one failing regression test). Creating a test is a bit tricky, since it does a pattern match on the Tree class in scalac, so the test could become rather large...

@scabug
Copy link
Author

scabug commented Dec 2, 2014

@retronym said:
The test case could (initially) still be based on a pattern match on compiler Trees. If you can get it that far (separated from Scala-JS), I can help to disentangle it further.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@gbasler said (edited on Dec 3, 2014 10:54:44 PM UTC):
Here's the patch:
https://github.com/gbasler/scala/commits/ticket/SI-8999

It contains a regression test that I created from the big pattern match in OptimizerCore in scala-js.
The remaining problem is that the warning that is reported is not stable since it can not generate all missing counter examples.
I tried to increase the recursion depth and/or cut down the test case, without any luck. Whenever I managed to make it small enough, it was also compiling under 2.11.4. Maybe you are more lucky...

Is it possible to ignore the output for this particular regression test und just check if the compiler crashes or not?

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@retronym said:
You can add -nowarn to the t8999.flags file that sits beside test/files/pos/t8999.scala.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@retronym said:
Before you submit a PR, can you also tweak the line wrapping in the commit message, some lines are too long.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@gbasler said:
Ouch. Sure, I wanted to add some more comments anyway.

@scabug
Copy link
Author

scabug commented Dec 4, 2014

@retronym said:
/cc @adriaanm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants