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 #731

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

JakubSchwenkbeck
Copy link
Contributor

@JakubSchwenkbeck JakubSchwenkbeck commented Dec 9, 2024

Motivation

Print and log a more verbose compiler crash/panic message with information about the specific user setup
Resolves #576.

Changes

Implemented the generateCrashReport function, which creates a more verbose output if the compiler crashes/panics.
This Report retrieves general and backend-specific information to make crashes more reproducable or traceable

It holds information about :

  • Effekt Version
  • Backend
  • OS
  • JVM
  • and a full stacktrace.

Additionally, the report is written to a .md-file in the .out/ directory

Testing

I added INTERNAL_ERROR("some text here") to the compileSource function in JVM/.../Driver.scala to crash the compiler and retrieve the new message

Printing example using INTERNAL_ERROR looks like this:

[info] === Effekt Compiler Crash Report ===

[Error] : Internal compiler error: some text here

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: https://github.com/effekt-lang/effekt/issues/new?labels=bug

Effekt Version: 0.10.0

Backend used: js

A detailed crash report has been written to:
/home/jakub/Effekt/effekt/bin/./out

Operating System: Linux

JVM Version: 21.0.5

Full Stack Trace:
PlainTextError(Internal compiler error: some text here,None,Error)
        at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
        at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
        at effekt.Driver.compileSource(Driver.scala:54)
        at effekt.Driver.compileSource$(Driver.scala:21)
        at effekt.Server$.compileSource(Server.scala:261)
        at effekt.Server$.compileSource(Server.scala:261)
        at kiama.util.Compiler.compileFile(Compiler.scala:102)
        at kiama.util.Compiler.compileFile$(Compiler.scala:22)
        at effekt.Server$.compileFile(Server.scala:261)
        at effekt.Driver.run$$anonfun$1(Driver.scala:41)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at effekt.Driver.run(Driver.scala:42)
        at effekt.Driver.run$(Driver.scala:21)
        at effekt.Server$.run(Server.scala:261)
        at effekt.Server$.run(Server.scala:261)
        at kiama.util.Compiler.driver(Compiler.scala:86)
        at kiama.util.Compiler.driver$(Compiler.scala:22)
        at effekt.Server$.driver(Server.scala:261)
        at kiama.util.Compiler.main(Compiler.scala:50)
        at kiama.util.Compiler.main$(Compiler.scala:22)
        at effekt.Server$.main(Server.scala:261)
        at effekt.Server.main(Server.scala)


Arguments passed to the compiler:

--backend=js
compilecrash.effekt

JakubSchwenkbeck and others added 2 commits December 9, 2024 18:56
… report with Information about : OS, JVM, a full stacktrace . Additionally, the crash report is written into a log file
Copy link
Member

@marvinborner marvinborner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I think there are some design/layout choices that we could discuss (e.g. emitting markdown for copy/pasting to GitHub), but otherwise this looks like a good initial implementation.

We should also make sure that things like the System.getProperty calls work on all platforms (including Windows!)

added correct Effekt Version
@JakubSchwenkbeck
Copy link
Contributor Author

Hey, thanks for the help with the Effekt Version!
I haven't compiled Effekt on Windows yet, maybe if there's time I could test this:)

Do you mean the markdown should be added to the written log? I don't see how much more a markdown could do for the readability opposed to the current way of pasting into a code-box, but I surely can implement the md-support aswell:)

@JakubSchwenkbeck
Copy link
Contributor Author

JakubSchwenkbeck commented Dec 11, 2024

Hey:) Would this be a desirable outcome when returning the log in .md? (@marvinborner )

# Effekt Compiler Crash Report

**Where to Report**: [https://github.com/effekt-lang/effekt/issues](https://github.com/effekt-lang/effekt/issues)



---

## Compiler Details
- **Effekt Compiler Version**: 0.10.0
- **Backend-specific info**:
  - **Name**: js
  - **Compiler**: `effekt.generator.js.JavaScriptNode@7c6908d7`
  - **Runner**: `effekt.JSNodeRunner$@3c9754d8`
- **Operating System**: Linux (amd64) `5.15.167.4-microsoft-standard-WSL2`
- **JVM Version**: `21.0.5 (Ubuntu)`

---

## Full Stack Trace
at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
at effekt.Driver.compileSource(Driver.scala:54)
at effekt.Driver.compileSource$(Driver.scala:21)
at effekt.Server$.compileSource(Server.scala:261)
at effekt.Server$.compileSource(Server.scala:261)
at kiama.util.Compiler.compileFile(Compiler.scala:102)
at kiama.util.Compiler.compileFile$(Compiler.scala:22)
at effekt.Server$.compileFile(Server.scala:261)
at effekt.Driver.run$$anonfun$1(Driver.scala:41)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at effekt.Driver.run(Driver.scala:42)
at effekt.Driver.run$(Driver.scala:21)
at effekt.Server$.run(Server.scala:261)
at effekt.Server$.run(Server.scala:261)
at kiama.util.Compiler.driver(Compiler.scala:86)
at kiama.util.Compiler.driver$(Compiler.scala:22)
at effekt.Server$.driver(Server.scala:261)
at kiama.util.Compiler.main(Compiler.scala:50)
at kiama.util.Compiler.main$(Compiler.scala:22)
at effekt.Server$.main(Server.scala:261)
at effekt.Server.main(Server.scala)

---

## Additional Info
- **Crash report saved to**: `./out/crash-report.log`

Effekt Compiler Crash Report

Where to Report: https://github.com/effekt-lang/effekt/issues


Compiler Details

  • Effekt Compiler Version: 0.10.0
  • Backend-specific info:
    • Name: js
    • Compiler: effekt.generator.js.JavaScriptNode@7c6908d7
    • Runner: effekt.JSNodeRunner$@3c9754d8
  • Operating System: Linux (amd64) 5.15.167.4-microsoft-standard-WSL2
  • JVM Version: 21.0.5 (Ubuntu)

Full Stack Trace

at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
at effekt.Driver.compileSource(Driver.scala:54)
at effekt.Driver.compileSource$(Driver.scala:21)
at effekt.Server$.compileSource(Server.scala:261)
at effekt.Server$.compileSource(Server.scala:261)
at kiama.util.Compiler.compileFile(Compiler.scala:102)
at kiama.util.Compiler.compileFile$(Compiler.scala:22)
at effekt.Server$.compileFile(Server.scala:261)
at effekt.Driver.run$$anonfun$1(Driver.scala:41)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at effekt.Driver.run(Driver.scala:42)
at effekt.Driver.run$(Driver.scala:21)
at effekt.Server$.run(Server.scala:261)
at effekt.Server$.run(Server.scala:261)
at kiama.util.Compiler.driver(Compiler.scala:86)
at kiama.util.Compiler.driver$(Compiler.scala:22)
at effekt.Server$.driver(Server.scala:261)
at kiama.util.Compiler.main(Compiler.scala:50)
at kiama.util.Compiler.main$(Compiler.scala:22)
at effekt.Server$.main(Server.scala:261)
at effekt.Server.main(Server.scala)

Additional Info

  • Crash report saved to: ./out/crash-report.log

@JakubSchwenkbeck JakubSchwenkbeck marked this pull request as ready for review December 16, 2024 13:34
@JakubSchwenkbeck
Copy link
Contributor Author

Hey:)
I completed my implementation and therefore switched from a draft to the PR.
I decided on logging the markdown version in a .md file and made some minor layout changes, an example is analog to the body of the main-comment, just with some md-specific highlighting

Copy link
Contributor

@jiribenes jiribenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JakubSchwenkbeck, this seems like a great first draft.
Please take a look at my comments below to guide the next steps! :)

effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
effekt/jvm/src/main/scala/effekt/Driver.scala Outdated Show resolved Hide resolved
@JakubSchwenkbeck
Copy link
Contributor Author

JakubSchwenkbeck commented Dec 17, 2024

What do you think of this Layout?

MARKDOWN:

Effekt Compiler Crash Report

[Error] : Internal compiler error: some text here

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: Submit an issue

Compiler Information

Effekt Version: 0.10.0

Backend: js

System Information

Operating System: Linux
Arch: amd64
Version: 5.15.167.4-microsoft-standard-WSL2

JVM Version: 21.0.5 (Ubuntu, /usr/lib/jvm/java-21-openjdk-amd64)

Full Stack Trace

  at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
  at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
  at effekt.Driver.compileSource(Driver.scala:54)
  at effekt.Driver.compileSource$(Driver.scala:21)
  at effekt.Server$.compileSource(Server.scala:261)
  at effekt.Server$.compileSource(Server.scala:261)
  at kiama.util.Compiler.compileFile(Compiler.scala:102)
  at kiama.util.Compiler.compileFile$(Compiler.scala:22)
  at effekt.Server$.compileFile(Server.scala:261)
  at effekt.Driver.run$$anonfun$1(Driver.scala:41)
  at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
  at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
  at scala.collection.immutable.List.foreach(List.scala:333)
  at effekt.Driver.run(Driver.scala:42)
  at effekt.Driver.run$(Driver.scala:21)
  at effekt.Server$.run(Server.scala:261)
  at effekt.Server$.run(Server.scala:261)
  at kiama.util.Compiler.driver(Compiler.scala:86)
  at kiama.util.Compiler.driver$(Compiler.scala:22)
  at effekt.Server$.driver(Server.scala:261)
  at kiama.util.Compiler.main(Compiler.scala:50)
  at kiama.util.Compiler.main$(Compiler.scala:22)
  at effekt.Server$.main(Server.scala:261)
  at effekt.Server.main(Server.scala)

Arguments Passed to the Compiler

compilecrash.effekt

TERMINAL:

[info] === Effekt Compiler Crash Report ===

[Error] : Internal compiler error: some text here

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: https://github.com/effekt-lang/effekt/issues/new?labels=bug

Effekt Version: 0.10.0

Backend used: js

A detailed crash report has been written to:
/home/jakub/Effekt/effekt/bin/./out/crash-report.md

Operating System: Linux

JVM Version: 21.0.5

Full Stack Trace:
at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
at effekt.Driver.compileSource(Driver.scala:54)
at effekt.Driver.compileSource$(Driver.scala:21)
at effekt.Server$.compileSource(Server.scala:261)
at effekt.Server$.compileSource(Server.scala:261)
at kiama.util.Compiler.compileFile(Compiler.scala:102)
at kiama.util.Compiler.compileFile$(Compiler.scala:22)
at effekt.Server$.compileFile(Server.scala:261)
at effekt.Driver.run$$anonfun$1(Driver.scala:41)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at effekt.Driver.run(Driver.scala:42)
at effekt.Driver.run$(Driver.scala:21)
at effekt.Server$.run(Server.scala:261)
at effekt.Server$.run(Server.scala:261)
at kiama.util.Compiler.driver(Compiler.scala:86)
at kiama.util.Compiler.driver$(Compiler.scala:22)
at effekt.Server$.driver(Server.scala:261)
at kiama.util.Compiler.main(Compiler.scala:50)
at kiama.util.Compiler.main$(Compiler.scala:22)
at effekt.Server$.main(Server.scala:261)
at effekt.Server.main(Server.scala)

Arguments passed to the compiler:

compilecrash.effekt

@jiribenes
Copy link
Contributor

jiribenes commented Dec 17, 2024

Could you please post the current version of the generated report here, please? :)

@JakubSchwenkbeck
Copy link
Contributor Author

The Current Terminal print :

[info] === Effekt Compiler Crash Report ===

[Error] : Internal compiler error: some text here

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: https://github.com/effekt-lang/effekt/issues/new?labels=bug

Effekt Version: 0.10.0

Backend used: js

A detailed crash report has been written to:
/home/jakub/Effekt/effekt/bin/./out

Operating System: Linux

JVM Version: 21.0.5

Full Stack Trace:
PlainTextError(Internal compiler error: some text here,None,Error)
        at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
        at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
        at effekt.Driver.compileSource(Driver.scala:54)
        at effekt.Driver.compileSource$(Driver.scala:21)
        at effekt.Server$.compileSource(Server.scala:261)
        at effekt.Server$.compileSource(Server.scala:261)
        at kiama.util.Compiler.compileFile(Compiler.scala:102)
        at kiama.util.Compiler.compileFile$(Compiler.scala:22)
        at effekt.Server$.compileFile(Server.scala:261)
        at effekt.Driver.run$$anonfun$1(Driver.scala:41)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at effekt.Driver.run(Driver.scala:42)
        at effekt.Driver.run$(Driver.scala:21)
        at effekt.Server$.run(Server.scala:261)
        at effekt.Server$.run(Server.scala:261)
        at kiama.util.Compiler.driver(Compiler.scala:86)
        at kiama.util.Compiler.driver$(Compiler.scala:22)
        at effekt.Server$.driver(Server.scala:261)
        at kiama.util.Compiler.main(Compiler.scala:50)
        at kiama.util.Compiler.main$(Compiler.scala:22)
        at effekt.Server$.main(Server.scala:261)
        at effekt.Server.main(Server.scala)


Arguments passed to the compiler:

--backend=js
compilecrash.effekt

@JakubSchwenkbeck
Copy link
Contributor Author

This is the markdown- log

Effekt Compiler Crash Report

ERROR : Internal compiler error: some text here

The compiler unexpectedly panicked. This is a compiler bug.
Please report it: Submit an issue

Compiler Information

Effekt Version: 0.10.0

Backend: js

System Information

Operating System: Linux
Arch: amd64
Version: 5.15.167.4-microsoft-standard-WSL2

JVM Version: 21.0.5 (Ubuntu, OpenJDK Runtime Environment)

Full Stack Trace

PlainTextError(Internal compiler error: some text here,None,Error)
	at effekt.util.messages$CompilerPanic$.apply(Messages.scala:37)
	at effekt.util.messages$.INTERNAL_ERROR(Messages.scala:53)
	at effekt.Driver.compileSource(Driver.scala:54)
	at effekt.Driver.compileSource$(Driver.scala:21)
	at effekt.Server$.compileSource(Server.scala:261)
	at effekt.Server$.compileSource(Server.scala:261)
	at kiama.util.Compiler.compileFile(Compiler.scala:102)
	at kiama.util.Compiler.compileFile$(Compiler.scala:22)
	at effekt.Server$.compileFile(Server.scala:261)
	at effekt.Driver.run$$anonfun$1(Driver.scala:41)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at effekt.Driver.run(Driver.scala:42)
	at effekt.Driver.run$(Driver.scala:21)
	at effekt.Server$.run(Server.scala:261)
	at effekt.Server$.run(Server.scala:261)
	at kiama.util.Compiler.driver(Compiler.scala:86)
	at kiama.util.Compiler.driver$(Compiler.scala:22)
	at effekt.Server$.driver(Server.scala:261)
	at kiama.util.Compiler.main(Compiler.scala:50)
	at kiama.util.Compiler.main$(Compiler.scala:22)
	at effekt.Server$.main(Server.scala:261)
	at effekt.Server.main(Server.scala)

Arguments Passed to the Compiler


--backend=js
compilecrash.effekt

@JakubSchwenkbeck
Copy link
Contributor Author

I'm flexible with the design, changing the layout / contet only needs minor String-manipulations, so feel free to knitpick:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom compiler crash/panic handler
3 participants