Skip to content

dotty compilation stackoverflow for huge number of cases classes #1257

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

Closed
liufengyun opened this issue May 17, 2016 · 4 comments
Closed

dotty compilation stackoverflow for huge number of cases classes #1257

liufengyun opened this issue May 17, 2016 · 4 comments
Assignees

Comments

@liufengyun
Copy link
Contributor

When I try to compile following file, dotty generates stackoverflow:

https://github.com/scala/scala/blob/2.12.x/test/files/neg/patmatexhaust-huge.scala

Stackoverflow happens after patmat and before erasure, one of following transform is dubious:

List(new VCInlineMethods,     // Inlines calls to value class methods
       new SeqLiterals,         // Express vararg arguments as arrays
       new InterceptedMethods,  // Special handling of `==`, `|=`, `getClass` methods
       new Getters,             // Replace non-private vals and vars with getter defs (fields are added later)
       new ElimByName,          // Expand by-name parameters and arguments
       new AugmentScala2Traits, // Expand traits defined in Scala 2.11 to simulate old-style rewritings
       new ResolveSuper,        // Implement super accessors and add forwarders to trait methods
       new ArrayConstructors),  // Intercept creation of (non-generic) arrays and intrinsify.
@odersky
Copy link
Contributor

odersky commented May 17, 2016

Suggestion: try to split the list to find out which mini=phase causes the stack overflow. E.g.

List(new VCInlineMethods,     // Inlines calls to value class methods
   new SeqLiterals,         // Express vararg arguments as arrays
   new InterceptedMethods,  // Special handling of `==`, `|=`, `getClass` methods
   new Getters,             // Replace non-private vals and vars with getter defs (fields are added later)
   new ElimByName),   // Expand by-name parameters and arguments
List(
   new AugmentScala2Traits, // Expand traits defined in Scala 2.11 to simulate old-style rewritings
   new ResolveSuper,        // Implement super accessors and add forwarders to trait methods
   new ArrayConstructors),  // Intercept creation of (non-generic) arrays and intrinsify.

@liufengyun liufengyun self-assigned this May 17, 2016
@liufengyun
Copy link
Contributor Author

Thanks @odersky for the tip, I self-assigned the issue and will look into it once I'm done with the patmat check.

@DarkDimius
Copy link
Contributor

The patmat may be generating a very deep tree in this case.
Simple way to solve this would be to pass -Xss 5M to JVM. I'd go with this way.
The patmat can also be changed not to nest DefDefs that define different cases into each other and instead have all them in the same level. I'd prefer not to do this, as it would may make common subexpression elimination harder to perform. Currently, even very simple CSE that has simple scoping rules can optimize our matches.

@liufengyun
Copy link
Contributor Author

As @DarkDimius commented, ./bin/dotc -J-Xss5M tests/patmat/patmatexhaust-huge.scala compiles without exception. Then I close this issue.

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

No branches or pull requests

3 participants