fix: run shell main on a thread with the configured stack size#14343
Merged
Conversation
This PR makes the `lean` driver run its main logic on a thread with the configured Lean stack size (1 GiB by default) instead of directly on the OS main thread, whose fixed default stack (often 8 MiB) is easily exhausted by the runtime's recursive algorithms. Previously, saving a deeply nested object graph to an `.olean` file (e.g. a persistent environment extension entry containing a list with about 100000 elements) aborted the whole process with a stack overflow, and `lean --run` failed on moderately deep non-tail recursion with a `deep recursion` error that `--tstack` could not actually raise. Compiled Lean executables already run `main` on a large-stack thread via `lean_run_main`; `lean_main` now mirrors this by running `run_shell_main` through a shared `run_with_thread_stack` helper. The driver now also honors `LEAN_STACK_SIZE_KB`, with `--tstack` taking precedence. Co-Authored-By: Claude <noreply@anthropic.com>
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the new 1GB stack size not being used for the main
leanthread itself, e.g. for serialization or--run.