Skip to content

OutOfMemoryError when missing inline modifier #12116

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
note opened this issue Apr 16, 2021 · 0 comments · Fixed by #12139
Closed

OutOfMemoryError when missing inline modifier #12116

note opened this issue Apr 16, 2021 · 0 comments · Fixed by #12139

Comments

@note
Copy link

note commented Apr 16, 2021

Compiler version

3.0.0-RC2

Minimized code

Mind the missing inline before erasedValue[T]. With inline erasedValue[T] it works as expected

inline def length[T]: Int =
    erasedValue[T] match
        case _: (h *: t) => 1 + length[t]
        case _: EmptyTuple => 0

Output

[info] compiling 1 Scala source to /Users/michal/programming/scala/scala3-example-project/target/scala-3.0.0-RC2/classes 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "classloader-cache-cleanup-0"
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 18, 2021
In some situations Typer tries several alternatives around an inlined call. If overflow is detected
at depth 32 then this could cause 2^32 different retries which leads to OOM.

Prevent this with a switch that stops further inline calls as long as an overflowing call stack
is not completely unwound.

Fixes scala#12116
michelou pushed a commit to michelou/scala3 that referenced this issue Apr 20, 2021
In some situations Typer tries several alternatives around an inlined call. If overflow is detected
at depth 32 then this could cause 2^32 different retries which leads to OOM.

Prevent this with a switch that stops further inline calls as long as an overflowing call stack
is not completely unwound.

Fixes scala#12116
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants