Overly large array allocation may panic with "integer overflow"
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend
Research direction
Start with the Array.replicate and ByteArray.emptyWithCapacity reproductions in the issue, then trace their runtime allocation paths and relevant tests. Reproduce the reported overflow with Lean 4.35.0 and compare interpreted and compiled behavior. Done means oversized requests are accepted or rejected gracefully without an uncaught runtime panic.
Written by the indexing model from the issue text.
Description
Prerequisites
- [ x] Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - [ x] Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
locally reproduced with nightly - When reporting a perceived soundness bug: Does it affect
lake check --paranoid?
If in doubt, please reach out on [email protected] for responsible disclosure.
Description
Minimal repro:
-- Repro.lean (lean-toolchain: leanprover/lean4:v4.35.0)
def main : IO Unit := do
let n : Nat := 2^61 -- 2^61 * sizeof(void*) overflows size_t on 64-bit
IO.println s!"allocating Array of {n} elements"
let a := Array.replicate n (0 : Nat)
IO.println s!"size = {a.size}"
$ lean --run Repro.lean
INTERNAL PANIC: integer overflow in runtime computation (exit 1)
Variants:
┌───────────────────────────────────────────────┬─────────────────────────────────────────────────────────┐
│ Case │ Interpreted and compiled │
├───────────────────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Array.replicate (2^60) │ INTERNAL PANIC: out of memory │
├───────────────────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Array.replicate (2^61) │ INTERNAL PANIC: integer overflow in runtime computation │
├───────────────────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ ByteArray.emptyWithCapacity (2^63) and (2^64) │ out of memory │
├───────────────────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Array.replicate (2^61) inside try … catch │ still aborts; not catchable │
└───────────────────────────────────────────────┴─────────────────────────────────────────────────────────┘
Expected behavior: [Clear and concise description of what you expect to happen]
Accept the program or a graceful rejection instead of a panic.
Actual behavior: [Clear and concise description of what actually happens]
Panic
Versions
4.35.0, reproduced on Linux and Mac.
Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
- Dominant language
- Lean
- Stars
- 10.3k
- Forks
- 1.1k
- Avg merge
- 19h 8m
- Merged PRs (30d)
- 421
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from leanprover/lean4
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
leanprover/lean4#16305 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
leanprover/lean4#16299 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16257 ·
Maintainers usually reply within 1 day
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
leanprover/lean4#15683 ·
Maintainers usually reply within 1 day
All issues in leanprover/lean4
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vllm-project/vllm-sail#398 ·
Maintainers usually reply within 1 day
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every runPossibly taken @kc9ddi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TeraSky-OSS/backstage-plugins#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nightscout/nocturne#4057 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
opendatalab/MinerU#5800 · 2 comments ·
Maintainers usually reply within 1 day