aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldo.c16
-rw-r--r--ldo.h1
-rw-r--r--lstate.c2
3 files changed, 13 insertions, 6 deletions
diff --git a/ldo.c b/ldo.c
index 958b1b7d..c92573d6 100644
--- a/ldo.c
+++ b/ldo.c
@@ -94,10 +94,6 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
94 setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ 94 setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */
95 break; 95 break;
96 } 96 }
97 case LUA_ERRERR: {
98 setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
99 break;
100 }
101 case LUA_OK: { /* special case only for closing upvalues */ 97 case LUA_OK: { /* special case only for closing upvalues */
102 setnilvalue(s2v(oldtop)); /* no error message */ 98 setnilvalue(s2v(oldtop)); /* no error message */
103 break; 99 break;
@@ -199,6 +195,16 @@ static void correctstack (lua_State *L) {
199/* some space for error handling */ 195/* some space for error handling */
200#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) 196#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200)
201 197
198
199/* raise an error while running the message handler */
200l_noret luaD_errerr (lua_State *L) {
201 TString *msg = luaS_newliteral(L, "error in error handling");
202 setsvalue2s(L, L->top.p, msg);
203 L->top.p++; /* assume EXTRA_STACK */
204 luaD_throw(L, LUA_ERRERR);
205}
206
207
202/* 208/*
203** Reallocate the stack to a new size, correcting all pointers into it. 209** Reallocate the stack to a new size, correcting all pointers into it.
204** In ISO C, any pointer use after the pointer has been deallocated is 210** In ISO C, any pointer use after the pointer has been deallocated is
@@ -248,7 +254,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) {
248 a stack error; cannot grow further than that. */ 254 a stack error; cannot grow further than that. */
249 lua_assert(stacksize(L) == ERRORSTACKSIZE); 255 lua_assert(stacksize(L) == ERRORSTACKSIZE);
250 if (raiseerror) 256 if (raiseerror)
251 luaD_throw(L, LUA_ERRERR); /* error inside message handler */ 257 luaD_errerr(L); /* error inside message handler */
252 return 0; /* if not 'raiseerror', just signal it */ 258 return 0; /* if not 'raiseerror', just signal it */
253 } 259 }
254 else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ 260 else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */
diff --git a/ldo.h b/ldo.h
index 56008ab3..4de9540e 100644
--- a/ldo.h
+++ b/ldo.h
@@ -60,6 +60,7 @@
60/* type of protected functions, to be ran by 'runprotected' */ 60/* type of protected functions, to be ran by 'runprotected' */
61typedef void (*Pfunc) (lua_State *L, void *ud); 61typedef void (*Pfunc) (lua_State *L, void *ud);
62 62
63LUAI_FUNC l_noret luaD_errerr (lua_State *L);
63LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 64LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
64LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 65LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
65 const char *mode); 66 const char *mode);
diff --git a/lstate.c b/lstate.c
index 7fefacba..89c8b6ad 100644
--- a/lstate.c
+++ b/lstate.c
@@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) {
166 if (getCcalls(L) == LUAI_MAXCCALLS) 166 if (getCcalls(L) == LUAI_MAXCCALLS)
167 luaG_runerror(L, "C stack overflow"); 167 luaG_runerror(L, "C stack overflow");
168 else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) 168 else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11))
169 luaD_throw(L, LUA_ERRERR); /* error while handling stack error */ 169 luaD_errerr(L); /* error while handling stack error */
170} 170}
171 171
172 172