Skip to content

extending javax.swing.SwingWorker from inner class causes crash #16343

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
flomebul opened this issue Nov 14, 2022 · 0 comments · Fixed by #16381
Closed

extending javax.swing.SwingWorker from inner class causes crash #16343

flomebul opened this issue Nov 14, 2022 · 0 comments · Fixed by #16381

Comments

@flomebul
Copy link
Contributor

flomebul commented Nov 14, 2022

Compiler version

Scala 3.2.1

Minimized code

class Issue16343:
  class MyWorker extends javax.swing.SwingWorker[Unit, Unit]

Output (click arrow to expand)

scalac: java.lang.StackOverflowError while running MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks} on E:\Users\Luc\Documents\Home\ProjIntl\Scala_3.2\src\main\scala\scala_3_2\Issue7894569.scala
scalac: java.lang.StackOverflowError while compiling E:\Users\Luc\Documents\Home\ProjIntl\Scala_3.2\src\main\scala\scala_3_2\Issue7894569.scala
scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.StackOverflowError
	at dotty.tools.dotc.core.Names$TermName.derived(Names.scala:207)
	at dotty.tools.dotc.core.NameKinds$QualifiedNameKind.apply(NameKinds.scala:131)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.dotty$tools$dotc$core$SymDenotations$SymDenotation$$_$qualify$1(SymDenotations.scala:494)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$1.applyOrElse(SymDenotations.scala:497)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$1.applyOrElse(SymDenotations.scala:496)
	at scala.PartialFunction$OrElse.apply(PartialFunction.scala:266)
	at dotty.tools.dotc.core.Names$SimpleName.replace(Names.scala:342)
	at dotty.tools.dotc.core.Names$SimpleName.replace(Names.scala:341)
	at dotty.tools.dotc.core.Names$Name.replaceDeep(Names.scala:81)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.fullNameSeparated(SymDenotations.scala:497)
	at dotty.tools.dotc.core.NameOps$.expandedName(NameOps.scala:145)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$outerAccName(ExplicitOuter.scala:199)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessor(ExplicitOuter.scala:194)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessors(ExplicitOuter.scala:140)
	at dotty.tools.dotc.transform.ExplicitOuter.transformInfo(ExplicitOuter.scala:53)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform(DenotTransformers.scala:42)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform$(DenotTransformers.scala:34)
	at dotty.tools.dotc.transform.ExplicitOuter.transform(ExplicitOuter.scala:36)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:833)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:882)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:120)
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:114)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:107)
	at dotty.tools.dotc.core.Symbols$ClassSymbol.classDenot(Symbols.scala:460)
	at dotty.tools.dotc.core.Symbols$.toClassDenot(Symbols.scala:500)
	at dotty.tools.dotc.core.Contexts$Context.effectiveScope(Contexts.scala:272)
	at dotty.tools.dotc.core.Contexts$Context.nestingLevel(Contexts.scala:275)
	at dotty.tools.dotc.core.Symbols$.newSymbol$default$8(Symbols.scala:522)
	at dotty.tools.dotc.transform.ExplicitOuter$.newOuterSym(ExplicitOuter.scala:182)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessor(ExplicitOuter.scala:195)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessors(ExplicitOuter.scala:140)
	at dotty.tools.dotc.transform.ExplicitOuter.transformInfo(ExplicitOuter.scala:53)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform(DenotTransformers.scala:42)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform$(DenotTransformers.scala:34)
	at dotty.tools.dotc.transform.ExplicitOuter.transform(ExplicitOuter.scala:36)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:833)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:882)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:120)
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:114)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:107)
	at dotty.tools.dotc.core.Symbols$ClassSymbol.classDenot(Symbols.scala:460)
	at dotty.tools.dotc.core.Symbols$.toClassDenot(Symbols.scala:500)
	at dotty.tools.dotc.core.Contexts$Context.effectiveScope(Contexts.scala:272)
	at dotty.tools.dotc.core.Contexts$Context.nestingLevel(Contexts.scala:275)
	at dotty.tools.dotc.core.Symbols$.newSymbol$default$8(Symbols.scala:522)
	at dotty.tools.dotc.transform.ExplicitOuter$.newOuterSym(ExplicitOuter.scala:182)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessor(ExplicitOuter.scala:195)
	at dotty.tools.dotc.transform.ExplicitOuter$.dotty$tools$dotc$transform$ExplicitOuter$$$newOuterAccessors(ExplicitOuter.scala:140)
	at dotty.tools.dotc.transform.ExplicitOuter.transformInfo(ExplicitOuter.scala:53)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform(DenotTransformers.scala:42)
	at dotty.tools.dotc.core.DenotTransformers$InfoTransformer.transform$(DenotTransformers.scala:34)
	at dotty.tools.dotc.transform.ExplicitOuter.transform(ExplicitOuter.scala:36)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:833)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:882)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:120)
...
...
@flomebul flomebul added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 14, 2022
@bishabosha bishabosha changed the title Crash with very simple class extending javax.swing.SwingWorker from inner class causes crash Nov 15, 2022
@bishabosha bishabosha added area:transform and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 15, 2022
odersky added a commit that referenced this issue Nov 19, 2022
When transforming a class at ExplicitOuter we create outer accessors for
it. The newSymbol call to do this takes place at phase ExplicitOuter +
1, but its arguments need to be evaluated at phase ExplicitOuter. This
was not true for the nestingLevel argument, which demanded the
denotation of the class at phase ExplicitOuter + 1, thus leading to the
SO.

Interestingly, the same path is not taken if the class has all abstract
members defined or is declared abstract. It's only in the error case
that I could reproduce the SO.

Fixes #16343
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 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