JDK-8338567 : Deeply nested synchronized crashes javac
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 24
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2024-08-19
  • Updated: 2024-10-28
  • Resolved: 2024-10-24
Related Reports
Relates :  
Description
The attached program crashes javac. I've reproduced the crash on a 24 debug build and a 21 release build. I'm guessing some limit/check on the nesting level is missing?

$ javac TestNestedSynchronize800.java


The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
	at jdk.compiler/com.sun.tools.javac.code.Types.hashCode(Types.java:4177)
	at jdk.compiler/com.sun.tools.javac.code.Types.hashCode(Types.java:4173)
	at jdk.compiler/com.sun.tools.javac.code.Types$UniqueType.hashCode(Types.java:4891)
	at java.base/java.util.HashMap.hash(HashMap.java:338)
	at java.base/java.util.HashMap.getNode(HashMap.java:577)
	at java.base/java.util.HashMap.get(HashMap.java:565)
	at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter$WriteablePoolHelper.writeIfNeeded(PoolWriter.java:351)
	at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.putClass(PoolWriter.java:119)
	at jdk.compiler/com.sun.tools.javac.jvm.PoolWriter.putConstant(PoolWriter.java:188)
	at jdk.compiler/com.sun.tools.javac.jvm.Code.emitLdc(Code.java:405)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSelect(Gen.java:2373)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2571)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:2092)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:2075)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:859)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSynchronized(Gen.java:1488)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSynchronized.accept(JCTree.java:1469)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:588)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:623)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:609)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:660)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.internalVisitBlock(Gen.java:1121)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1085)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1133)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:588)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:623)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:609)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genTry(Gen.java:1559)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSynchronized(Gen.java:1513)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSynchronized.accept(JCTree.java:1469)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:588)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:623)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:609)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:660)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.internalVisitBlock(Gen.java:1121)
	at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1085)

...
Comments
[~vromero] All right, fair enough!
25-10-2024

at some point bugs due to lack of resources fail again once a given limit gets passed. I think that fix for JDK-8322992 addresses this issue. Also debug VMs usually consume more memory so probably not the best testing environment for this type of issues. Also JDK-8322992 got fixed in 23 so it is expected that you won't see the effect in a 21 distro
24-10-2024

It seems the fix for JDK-8322992 was perhaps incomplete?
19-08-2024