Stack overflow on malformed input
TwoFX opened this issue · comments
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - 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”)
Description
The following malformed input causes Lean to crash with a stack overflow:
structure D:=(t:A)(c N:={s with} 0
Here is the repeating part of the call stack from gdb:
#26501 0x00007ffff540023d in l_Lean_Elab_Term_withAutoBoundImplicit_loop___rarg (x_1=0x7ffff1365938, x_2=0x7ffff136acf8, x_3=0x7ffff120eae0, x_4=0x7ffff12feae8, x_5=0x7ffff1d489b8, x_6=0x7ffff12fec08, x_7=0x7ffff1258858,
x_8=0x7ffff12fe8a8, x_9=0x1) at ../build/debug/stage1/lib/temp/Lean/Elab/Term.c:45232
#26502 0x00007ffff53ff851 in l_Lean_Elab_Term_withAutoBoundImplicit_loop___rarg___lambda__1 (x_1=0x7ffff1365938, x_2=0x7ffff136ada0, x_3=0x7ffff120eae0, x_4=0x7ffff12feae8, x_5=0x7ffff1d489b8, x_6=0x7ffff12fec08, x_7=0x7ffff1258858,
x_8=0x7ffff12fe8a8, x_9=0x1) at ../build/debug/stage1/lib/temp/Lean/Elab/Term.c:45086
#26503 0x00007ffff7219009 in lean::lean_apply_8 (f=0x7ffff1366cb8, a1=0x7ffff136ada0, a2=0x7ffff120eae0, a3=0x7ffff12feae8, a4=0x7ffff1d489b8, a5=0x7ffff12fec08, a6=0x7ffff1258858, a7=0x7ffff12fe8a8, a8=0x1)
at /home/markus/code/lean4/src/runtime/apply.cpp:510
#26504 0x00007ffff5383e17 in l_Lean_Meta_withLocalDecl___at_Lean_Elab_Term_withAuxDecl___spec__1___rarg___lambda__1 (x_1=0x7ffff1366cb8, x_2=0x7ffff120eae0, x_3=0x7ffff12feae8, x_4=0x7ffff136ada0, x_5=0x7ffff1d489b8, x_6=0x7ffff12fec08,
x_7=0x7ffff1258858, x_8=0x7ffff12fe8a8, x_9=0x1) at ../build/debug/stage1/lib/temp/Lean/Elab/Term.c:7263
#26505 0x00007ffff72153a3 in lean::lean_apply_6 (f=0x7ffff1371ce8, a1=0x7ffff136ada0, a2=0x7ffff1d489b8, a3=0x7ffff12fec08, a4=0x7ffff1258858, a5=0x7ffff12fe8a8, a6=0x1) at /home/markus/code/lean4/src/runtime/apply.cpp:406
#26506 0x00007ffff6278dab in l___private_Lean_Meta_Basic_0__Lean_Meta_withNewFVar___rarg (x_1=0x7ffff136ada0, x_2=0x7ffff136af98, x_3=0x7ffff1371ce8, x_4=0x7ffff1d489b8, x_5=0x7ffff12fec08, x_6=0x7ffff1258858, x_7=0x7ffff12fe8a8, x_8=0x1)
at ../build/debug/stage1/lib/temp/Lean/Meta/Basic.c:23052
#26507 0x00007ffff6279147 in l___private_Lean_Meta_Basic_0__Lean_Meta_withLocalDeclImp___rarg (x_1=0x7ffff1362238, x_2=1 '\001', x_3=0x7ffff136af98, x_4=0x7ffff1371ce8, x_5=0 '\000', x_6=0x7ffff1d489b8, x_7=0x7ffff12fec08,
x_8=0x7ffff1258858, x_9=0x7ffff12fe8a8, x_10=0x1) at ../build/debug/stage1/lib/temp/Lean/Meta/Basic.c:23128
#26508 0x00007ffff5383ed8 in l_Lean_Meta_withLocalDecl___at_Lean_Elab_Term_withAuxDecl___spec__1___rarg (x_1=0x7ffff1362238, x_2=1 '\001', x_3=0x7ffff136af98, x_4=0x7ffff1366cb8, x_5=0 '\000', x_6=0x7ffff120eae0, x_7=0x7ffff12feae8,
x_8=0x7ffff1d489b8, x_9=0x7ffff12fec08, x_10=0x7ffff1258858, x_11=0x7ffff12fe8a8, x_12=0x1) at ../build/debug/stage1/lib/temp/Lean/Elab/Term.c:7275
#26509 0x00007ffff540023d in l_Lean_Elab_Term_withAutoBoundImplicit_loop___rarg (x_1=0x7ffff1365938, x_2=0x7ffff136af98, x_3=0x7ffff120eae0, x_4=0x7ffff12feae8, x_5=0x7ffff1d489b8, x_6=0x7ffff12fec08, x_7=0x7ffff1258858,
x_8=0x7ffff12fe8a8, x_9=0x1) at ../build/debug/stage1/lib/temp/Lean/Elab/Term.c:45232
Context
Discovered through fuzzing, so probably low priority.
Steps to Reproduce
- Copy the snippet above into live.lean-lang.org or run it locally
Expected behavior: Lean exits gracefully with an error message.
Actual behavior: Stack overflow detected. Aborting.
Versions
Lean (version 4.9.0, commit fe7b96d, DEBUG)
Linux markus-laptop 6.8.9-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 07 May 2024 21:35:54 +0000 x86_64 GNU/Linux
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.