From 3d06d35bf644a006c2de1c871b30e9c18888c8ec Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 11 Aug 2019 23:56:24 -0500 Subject: [PATCH] lua rock events crash on error in main state on errors thread stack overflows yielding before thread_exit() is a bad idea apparently Change-Id: Iac45d4321fac496738384fdbbeb480356ef2a1bb --- apps/plugins/lua/rocklib_events.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/plugins/lua/rocklib_events.c b/apps/plugins/lua/rocklib_events.c index 270c4ab393..09f1c2fd8a 100644 --- a/apps/plugins/lua/rocklib_events.c +++ b/apps/plugins/lua/rocklib_events.c @@ -72,6 +72,7 @@ #define EVENT_METATABLE "event metatable" #define EVENT_THREAD LUA_ROCKEVENTSNAME ".thread" +#define EV_STACKSZ DEFAULT_STACK_SIZE #define LUA_SUCCESS 0 #define EV_TIMER_FREQ (TIMER_FREQ / HZ) @@ -323,7 +324,7 @@ event_error: /* thread is exiting -- clean up */ rb->timer_unregister(); - rb->yield(); + //rb->yield(); rb->thread_exit(); return; @@ -360,7 +361,7 @@ static void create_event_thread_ref(struct event_data *ev_data) lua_createtable(L, 2, 0); - ev_data->event_stack = (long *) lua_newuserdata (L, DEFAULT_STACK_SIZE); + ev_data->event_stack = (long *) lua_newuserdata (L, EV_STACKSZ); /* attach EVENT_METATABLE to ud so we get notified on garbage collection */ luaL_getmetatable (L, EVENT_METATABLE); @@ -412,7 +413,7 @@ static void init_event_thread(bool init, struct event_data *ev_data) ev_data->thread_id = rb->create_thread(&event_thread, ev_data->event_stack, - DEFAULT_STACK_SIZE, + EV_STACKSZ, 0, EVENT_THREAD IF_PRIO(, PRIORITY_SYSTEM)