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

Custom compiler crash/panic handler #576

Open
jiribenes opened this issue Sep 6, 2024 · 2 comments · May be fixed by #731
Open

Custom compiler crash/panic handler #576

jiribenes opened this issue Sep 6, 2024 · 2 comments · May be fixed by #731
Labels

Comments

@jiribenes
Copy link
Contributor

jiribenes commented Sep 6, 2024

Motivation

Since we're planning on having a few more users soon, it would be nice to print more information when crashing so that the crash is easier to reproduce.

Description

When the compiler crashes/panics, produce a slightly larger report with the necessary information one needs to report the crash, such as:

  • where to report the crash
  • Effekt compiler version
  • Effekt config (esp. things like which backend was used)
  • JVM info
  • backend info (paths, versions of installed/used backends?)
  • OS info
  • the full stack trace

This could also be serialised into some file in ./out/ instead of / in addition to printing it.

Context

The relevant code for handling a crash right now is here:

} catch {
case FatalPhaseError(msg) => context.report(msg)
case e @ CompilerPanic(msg) =>
context.report(msg)
e.getStackTrace.foreach { line =>
context.info(" at " + line)
}
// when in server-mode, do not crash but report the error to avoid
// restarting the server.
case e if config.server() =>
context.info("Effekt Compiler Crash: " + e.getMessage)
e.getStackTrace.foreach { line =>
context.info(" at " + line)
}

Most of the info mentioned above is accessible via System.getProperty (or via System.getenv) or through the EffektConfig. :)

@JakubSchwenkbeck
Copy link
Contributor

Hey @jiribenes :)
I started to tackle this one and got pretty far, but now I have a somewhat embarrassing question. I can't get the compiler to crash so I can test my implementation... I thought this might even be the easiest part, but all the things I tried are caught by other safeties!! Could you provide me with a fool-proof way to crash or panic the compiler?:)

@jiribenes
Copy link
Contributor Author

It's great news that you find it hard to make the compiler panic ;), that means we're making it pretty resilient. :)

In order to test this feature, try putting INTERNAL_ERROR("some text here") somewhere into the compiler source where it's going to get hit (this specific helper is defined in util/Messages.scala)

@JakubSchwenkbeck JakubSchwenkbeck linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants