Skip to content

Commit 4abdfec

Browse files
committed
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.
1 parent fbc9d0a commit 4abdfec

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,21 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
482482

483483
private def verifySignature(sym: Symbol, sig: String)(implicit ctx: Context): Unit = {
484484
import scala.tools.asm.util.CheckClassAdapter
485-
def wrap(body: => Unit): Boolean =
486-
try { body; true }
487-
catch { case ex: Throwable => println(ex.getMessage); false }
485+
def wrap(body: => Unit): Unit = {
486+
try body
487+
catch {
488+
case ex: Throwable =>
489+
throw new Exception(
490+
i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
491+
|signature: $sig
492+
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
493+
""".trim,
494+
ex
495+
)
496+
}
497+
}
488498

489-
val valid = wrap {
499+
wrap {
490500
if (sym.is(Flags.Method)) {
491501
CheckClassAdapter.checkMethodSignature(sig)
492502
}
@@ -497,14 +507,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
497507
CheckClassAdapter.checkClassSignature(sig)
498508
}
499509
}
500-
501-
if (!valid) {
502-
ctx.error(
503-
i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
504-
|signature: $sig
505-
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
506-
""".trim, sym.sourcePos)
507-
}
508510
}
509511

510512
/**

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
180180
try { /*withCurrentUnit(item.cunit)*/(visit(item)) }
181181
catch {
182182
case ex: Throwable =>
183-
ex.printStackTrace()
184-
ctx.error(s"Error while emitting ${int.sourceFileFor(item.cunit)}\n${ex.getMessage}")
183+
throw new Exception(s"Error while emitting ${int.sourceFileFor(item.cunit)}", ex)
185184
}
186185
}
187186
}
@@ -414,8 +413,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
414413
addToQ3(item)
415414
} catch {
416415
case ex: Throwable =>
417-
ex.printStackTrace()
418-
ctx.error(s"Error while emitting ${item.plain.classNode.name}\n${ex.getMessage}")
416+
throw new Exception(s"Error while emitting ${item.plain.classNode.name}", ex)
419417
}
420418
}
421419
}

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,19 +852,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
852852
extends Test(testSources, times, threadLimit, suppressAllOutput) {
853853
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
854854
def checkTestSource(): Unit = tryCompile(testSource) {
855-
def fail(msg: String): Nothing = {
855+
def fail(msg: String): Unit = {
856856
echo(msg)
857857
failTestSource(testSource)
858-
???
859858
}
860859
testSource match {
861860
case testSource@JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) =>
862861
val sourceFiles = testSource.sourceFiles
863-
val reporter =
864-
try compile(sourceFiles, flags, true, outDir)
865-
catch {
866-
case ex: Throwable => fail(s"Fatal compiler crash when compiling: ${testSource.title}")
867-
}
862+
val reporter = compile(sourceFiles, flags, true, outDir)
868863
if (reporter.compilerCrashed)
869864
fail(s"Compiler crashed when compiling: ${testSource.title}")
870865
case testSource@SeparateCompilationSource(_, dir, flags, outDir) => unsupported("NoCrashTest - SeparateCompilationSource")

0 commit comments

Comments
 (0)