Skip to content
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

Log all errors caught in the frontend at debug level #1618

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/src/main/scala/stainless/frontend/ThreadedFrontend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ abstract class ThreadedFrontend(callback: CallBack, ctx: inox.Context) extends F
initRun()
callback.beginExtractions()
onRun()
} catch {
case e: Throwable => {
// `BatchedCallBack.endExtractions` and
// `SplitCallBack.endExtractions` only run if there are no errors
// reported. Not reporting errors here allow them to potentially
// recover from some errors.
//
// Matt: Do we really want that? From which errors can they actually
// recover? There might be non-recoverable exceptions benefiting
// from being reported here already or in handler below, either as
// errors or as warnings. See #1618 for more context.
ctx.reporter.debug("The following exception has been caught in the frontend init or run:")
ctx.reporter.debug(e)
}
} finally {
callback.endExtractions()
onEnd()
Expand All @@ -45,6 +59,8 @@ abstract class ThreadedFrontend(callback: CallBack, ctx: inox.Context) extends F
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
override def uncaughtException(t: Thread, e: Throwable): Unit = {
ThreadedFrontend.this.synchronized(exceptions += e)
ctx.reporter.debug("The following exception has been caught in the frontend end:")
ctx.reporter.debug(e)
}
})

Expand All @@ -69,9 +85,8 @@ abstract class ThreadedFrontend(callback: CallBack, ctx: inox.Context) extends F
case UnsupportedCodeException(pos, msg) =>
ctx.reporter.error(pos, msg)
case _ =>
ctx.reporter.debug(s"Rethrowing exception emitted from within the compiler: ${ex.getMessage}")
ctx.reporter.debug(s"Rethrowing the first exception caught in the frontend end: ${ex.getMessage}.")
exceptions.clear()
throw ex
}
}