leanprover / leanprover/lean4

`panic`ing in the interpreter

Open
#67 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

@Kha when panic is evaluated by the interpreter, the execution is interrupted as expected.
However, all trace messages produced using dbgTrace are lost because the #eval command implementation redirects stdout to a buffer.
Not sure what the best fix is. Here are some alternatives:
1- We register finalizers for panic. Then, #eval can set a finalizer that just dumps any intermediate output to stdout before terminating the execution.
2- We throw a C++ exception at panic instead of aborting. We will leak memory, but #eval will be able to dump the output as trace messages, and then terminate the Lean process with a panic message.
3- We don't change panic, but the interpreter intercepts it and uses a different implementation. Example: store error message, and continue the execution with the "arbitrary" element. Pro: no leaks. Cons: the computation is nonsense after the first panic, and it may diverge.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the #eval command implementation and the handling of panic and dbgTrace. Compare the three alternatives described in the issue, then determine how trace output can be preserved without leaving execution in an invalid state. Done means panic still terminates evaluation correctly and intermediate dbgTrace messages reach stdout.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.