AP_Scripting: prevent a code path to abort() in scripting

if scripting can't find an error handler it can call abort(). We don't
ever want to do that in ArduPilot
This commit is contained in:
Andrew Tridgell 2024-02-07 09:35:42 +11:00
parent 4ad1231c8f
commit f8097379cb
3 changed files with 22 additions and 1 deletions

View File

@ -128,7 +128,7 @@ l_noret luaD_throw (lua_State *L, int errcode) {
lua_unlock(L);
g->panic(L); /* call panic function (last chance to jump out) */
}
abort();
lua_abort();
}
}
}

View File

@ -956,4 +956,23 @@ int lua_range_finder_handle_script_msg(lua_State *L) {
}
#endif
/*
lua wants to abort, and doesn't have access to a panic function
*/
void lua_abort()
{
INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
#if AP_SIM_ENABLED
AP_HAL::panic("lua_abort called");
#else
if (!hal.util->get_soft_armed()) {
AP_HAL::panic("lua_abort called");
}
// abort while flying, all we can do is loop
while (true) {
hal.scheduler->delay(1000);
}
#endif
}
#endif // AP_SCRIPTING_ENABLED

View File

@ -27,3 +27,5 @@
#endif // REPL_OUT
int lua_get_current_ref();
void lua_abort(void) __attribute__((noreturn));