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

Confusing crash on infinite loop in metaprogram #6172

Open
david-christiansen opened this issue Nov 22, 2024 · 0 comments
Open

Confusing crash on infinite loop in metaprogram #6172

david-christiansen opened this issue Nov 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@david-christiansen
Copy link
Contributor

Description

For some infinite loops, executing them in the interpreter leads to a crash with the message libc++abi: terminating due to uncaught exception of type lean::exception: unreachable code.

Context

This happened to me when I was working on a fairly complicated metaprogram involving environment extensions. It took a long time to figure out that it was an infinite loop - I'd have expected a program that didn't terminate, or one that crashed with the explicit infinite loop error, rather than this message.

Steps to Reproduce

Enter the following code:

import Lean
open Lean Elab Command

elab "#oops" : command => do
  let mut n : Nat := 0
  repeat
    n := n + 1
  logInfo (toString n)

#oops

Expected behavior:

Either nontermination, a heartbeats error, a maximum recursion depth error, or the "deep recursion" crash from this program:

import Lean
open Lean Elab Command

elab "#oops" : command => do
  repeat
    pure ()

#oops
libc++abi: terminating due to uncaught exception of type lean::throwable: deep recursion was detected at 'interpreter' (potential solution: increase stack space in your system)
interpreter stacktrace:

Actual behavior:

The Lean language server crashes with libc++abi: terminating due to uncaught exception of type lean::exception: unreachable code. This makes it difficult to figure out what's actually wrong, even when looking at it with lldb.

Versions

"4.12.0" and "4.14.0-rc2" both exhibit this on macOS 14.6.1.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@david-christiansen david-christiansen added the bug Something isn't working label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant