Skip to content

Inline crashing compiler with StackOverflowError. #1875

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
nicolasstucki opened this issue Jan 3, 2017 · 1 comment
Closed

Inline crashing compiler with StackOverflowError. #1875

nicolasstucki opened this issue Jan 3, 2017 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

The issue is that for any value -Xmax-inlines it is possible to construct a method that has the recursion deep enough to make the compiler crash with a StackOverflowError. We are currently just in the boundary to make neg/power.scala compile. The following code shows a simple way to create a method that will crash the compiler.

object Test {
  @inline
  def rec(n: Int): Unit = {
    {
      {
        {
          {
            {
              rec(n)
            }
          }
        }
      }
    }
  }

  def main(args: Array[String]): Unit = {
    rec(42)
  }
}

The simplest way to workaround this is to decrease the -Xmax-inlines. This is not a solution as it forces an upper bound on possible -Xmax-inlines.

We might need to take into account the deepness of the reclusive inlined code to limit the number of inlines.

We might also consider having an annotation to limit the recursion of a specific method.

@odersky
Copy link
Contributor

odersky commented Jan 4, 2017

I think it's fine to decrease max-inline's default to, say, 32. There's also another option for the user: increase stacksize. But in any case, it's always possible to write programs that cause stackoverflows in the compiler, whether you use inline or not.

@nicolasstucki nicolasstucki self-assigned this Jan 4, 2017
@odersky odersky closed this as completed in 0bb3af3 Jan 4, 2017
odersky added a commit that referenced this issue Jan 4, 2017
Fix #1875: Decrease -Xmax-inlines default to 32.
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

3 participants