[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/bytecode-speedup 7875ce7365 1/2: Don't crash on unbalanced unwin
From: |
Mattias Engdegård |
Subject: |
scratch/bytecode-speedup 7875ce7365 1/2: Don't crash on unbalanced unwinds in debug mode |
Date: |
Thu, 13 Jan 2022 12:27:37 -0500 (EST) |
branch: scratch/bytecode-speedup
commit 7875ce7365403522c6aa53c0ac892a6edb7403bd
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Don't crash on unbalanced unwinds in debug mode
* src/bytecode.c (exec_byte_code):
Restore the previous graceful error (instead of a hard crash) when the
bytecode doesn't unwind properly, but only when building with
debugging (NDEBUG not defined, checking enabled, or BYTE_CODE_SAFE
enabled).
---
src/bytecode.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/bytecode.c b/src/bytecode.c
index 41455629cb..0bca2546f7 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1588,10 +1588,17 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object
vector, Lisp_Object maxdepth,
exit:
+#if BYTE_CODE_SAFE || !defined NDEBUG
+ if (SPECPDL_INDEX () != count)
+ {
+ /* Binds and unbinds are supposed to be compiled balanced. */
+ if (SPECPDL_INDEX () > count)
+ unbind_to (count, Qnil);
+ error ("binding stack not balanced (serious byte compiler bug)");
+ }
+#endif
/* The byte code should have been properly pinned. */
eassert (SDATA (bytestr) == bytestr_data);
- /* Binds and unbinds are supposed to be compiled balanced. */
- eassert (SPECPDL_INDEX () == count);
Lisp_Object result = TOP;
SAFE_FREE ();