Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] luajit: fox for debug.getinfo(1,'>S')
@ 2019-08-08 14:12 sergos
  2019-08-15 11:35 ` [tarantool-patches] " Kirill Yukhin
  0 siblings, 1 reply; 2+ messages in thread
From: sergos @ 2019-08-08 14:12 UTC (permalink / raw)
  To: tarantool-patches

fix for the debug machinery in case an extra argument
is expected on Lua stack

Fixes: #3833

https://github.com/tarantool/luajit/tree/sergos/luajit-gh-509-debug-getinfo-crash
---
 src/lj_debug.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/lj_debug.c b/src/lj_debug.c
index 959dc28..73bd196 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -427,12 +427,16 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
   TValue *frame = NULL;
   TValue *nextframe = NULL;
   GCfunc *fn;
-  if (*what == '>') {
-    TValue *func = L->top - 1;
-    api_check(L, tvisfunc(func));
-    fn = funcV(func);
-    L->top--;
-    what++;
+  if (*what == '>') { /* we have to have an extra arg on stack */
+    if (lua_gettop(L) > 2) {
+      TValue *func = L->top - 1;
+      api_check(L, tvisfunc(func));
+      fn = funcV(func);
+      L->top--;
+      what++;
+    } else { /* need better error to display? */
+      return 0;
+    }
   } else {
     uint32_t offset = (uint32_t)ar->i_ci & 0xffff;
     uint32_t size = (uint32_t)ar->i_ci >> 16;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tarantool-patches] Re: [PATCH] luajit: fox for debug.getinfo(1,'>S')
  2019-08-08 14:12 [tarantool-patches] [PATCH] luajit: fox for debug.getinfo(1,'>S') sergos
@ 2019-08-15 11:35 ` Kirill Yukhin
  0 siblings, 0 replies; 2+ messages in thread
From: Kirill Yukhin @ 2019-08-15 11:35 UTC (permalink / raw)
  To: tarantool-patches

Hello,

On 08 Aug 14:12, sergos@tarantool.org wrote:
> fix for the debug machinery in case an extra argument
> is expected on Lua stack
> 
> Fixes: #3833
> 
> https://github.com/tarantool/luajit/tree/sergos/luajit-gh-509-debug-getinfo-crash

I've checked the patch into 1.10, 2.1, 2.2 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-15 11:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 14:12 [tarantool-patches] [PATCH] luajit: fox for debug.getinfo(1,'>S') sergos
2019-08-15 11:35 ` [tarantool-patches] " Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox