From 272fe21805d4b407acb93b92c3071a6561d104ff Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 30 Apr 2019 19:04:14 +0200 Subject: [PATCH 1/2] Fix #6403: Do not intercept crashes Emitting an error when the backend crashes hides the crash from the reporter and fails which cannot be identified by the testing framework. --- .../backend/jvm/DottyBackendInterface.scala | 24 +++++++++---------- .../dotty/tools/backend/jvm/GenBCode.scala | 8 +++---- .../dotty/tools/vulpix/ParallelTesting.scala | 9 ++----- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 74fd5b34c36d..38b3644c0f2c 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -482,11 +482,19 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma private def verifySignature(sym: Symbol, sig: String)(implicit ctx: Context): Unit = { import scala.tools.asm.util.CheckClassAdapter - def wrap(body: => Unit): Boolean = - try { body; true } - catch { case ex: Throwable => println(ex.getMessage); false } + def wrap(body: => Unit): Unit = { + try body + catch { + case ex: Throwable => + println(i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName} + |signature: $sig + |if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues + """.trim) + throw ex + } + } - val valid = wrap { + wrap { if (sym.is(Flags.Method)) { CheckClassAdapter.checkMethodSignature(sig) } @@ -497,14 +505,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma CheckClassAdapter.checkClassSignature(sig) } } - - if (!valid) { - ctx.error( - i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName} - |signature: $sig - |if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues - """.trim, sym.sourcePos) - } } /** diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala index ed0e8b14be79..f2ddc71c60d1 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -180,8 +180,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter try { /*withCurrentUnit(item.cunit)*/(visit(item)) } catch { case ex: Throwable => - ex.printStackTrace() - ctx.error(s"Error while emitting ${int.sourceFileFor(item.cunit)}\n${ex.getMessage}") + println(s"Error while emitting ${int.sourceFileFor(item.cunit)}") + throw ex } } } @@ -414,8 +414,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter addToQ3(item) } catch { case ex: Throwable => - ex.printStackTrace() - ctx.error(s"Error while emitting ${item.plain.classNode.name}\n${ex.getMessage}") + println(s"Error while emitting ${item.plain.classNode.name}") + throw ex } } } diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index fffb9bd78a55..9fb5afaa03dd 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -852,19 +852,14 @@ trait ParallelTesting extends RunnerOrchestration { self => extends Test(testSources, times, threadLimit, suppressAllOutput) { protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable { def checkTestSource(): Unit = tryCompile(testSource) { - def fail(msg: String): Nothing = { + def fail(msg: String): Unit = { echo(msg) failTestSource(testSource) - ??? } testSource match { case testSource@JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) => val sourceFiles = testSource.sourceFiles - val reporter = - try compile(sourceFiles, flags, true, outDir) - catch { - case ex: Throwable => fail(s"Fatal compiler crash when compiling: ${testSource.title}") - } + val reporter = compile(sourceFiles, flags, true, outDir) if (reporter.compilerCrashed) fail(s"Compiler crashed when compiling: ${testSource.title}") case testSource@SeparateCompilationSource(_, dir, flags, outDir) => unsupported("NoCrashTest - SeparateCompilationSource") From d1a54fe3ddc4a946f125ac6682123ca63affa2cf Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 1 May 2019 11:03:48 +0200 Subject: [PATCH 2/2] Use ctx.error --- .../src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 38b3644c0f2c..54826a6af1c6 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -486,10 +486,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma try body catch { case ex: Throwable => - println(i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName} + ctx.error(i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName} |signature: $sig |if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues - """.trim) + """.trim, sym.sourcePos) throw ex } }