RFR: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Apr 22 14:20:29 UTC 2024


On Thu, 18 Apr 2024 14:44:19 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> This is a fix to a memory issue but I'm not totally sure we should apply it. Basically the issue here is that javac is failing because of lack of resources for a very deeply nested sequence of blocks. I was tracing the root cause and I found the fix for: [JDK-8291769](https://bugs.openjdk.org/browse/JDK-8291769) to be the one starting from which the stack overflow issue started to happen. Basically method Gen::visitBlock as refactored by fix for [JDK-8291769](https://bugs.openjdk.org/browse/JDK-8291769) occupies more memory than before, at execution time space for local variables is reserved regardless and after the mentioned fix the method has more local variables.
>> 
>> This refactoring proposed here fixes the stack overflow for the reproductor provided in the bug entry but it could be that if we add more nested blocks then we can make the compiler fail at some point. So the merit of this fix is arguable. Still the bug could be valid for the reporter so let's discuss if this fix should be pushed or not.
>> 
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
> 
>   adding regression test

The solution seems reasonable to me. Maybe a comment in the `visitBlock` could help, but the a test may be enough.

Although this is probably not critical, I don't see a good reason to not include it - this should help with any deeply nested blocks, not only for synchronized statements.

Thanks!

-------------

Marked as reviewed by jlahoda (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/18832#pullrequestreview-2014902453


More information about the compiler-dev mailing list