From fb745cc5a882cd4e3a49ff1f565cb69a65575993 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 19 Aug 2017 01:05:18 +0200 Subject: [PATCH] Lua may call C++ functions with throw. Catch them --- libs/ardour/luaproc.cc | 9 +++++++-- libs/ardour/luascripting.cc | 6 +++--- libs/ardour/session.cc | 16 +++++++++++++--- libs/ardour/session_state.cc | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index 6581743771..c1fd455cdf 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -238,8 +238,7 @@ LuaProc::load_script () try { lua_dsp_init (_session.nominal_frame_rate ()); } catch (luabridge::LuaException const& e) { - ; - } + } catch (...) { } } _ctrl_params.clear (); @@ -354,6 +353,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan } } catch (luabridge::LuaException const& e) { _iotable = NULL; + } catch (...) { + _iotable = NULL; } } @@ -584,6 +585,8 @@ LuaProc::configure_io (ChanCount in, ChanCount out) std::cerr << "LuaException: " << e.what () << "\n"; #endif return false; + } catch (...) { + return false; } } } @@ -734,6 +737,8 @@ LuaProc::connect_and_run (BufferSet& bufs, std::cerr << "LuaException: " << e.what () << "\n"; #endif return -1; + } catch (...) { + return -1; } #ifdef WITH_LUAPROC_STATS int64_t t1 = g_get_monotonic_time (); diff --git a/libs/ardour/luascripting.cc b/libs/ardour/luascripting.cc index e2fc9d49f1..a63dc9ea48 100644 --- a/libs/ardour/luascripting.cc +++ b/libs/ardour/luascripting.cc @@ -385,7 +385,7 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname, } else { lua.do_command (s); } - } catch (luabridge::LuaException const& e) { + } catch (...) { return rv; } @@ -482,7 +482,7 @@ LuaScripting::try_compile (const std::string& script, const LuaScriptParamList& cerr << e.what() << "\n"; #endif lua_print (e.what()); - } + } catch (...) { } return false; } @@ -513,7 +513,7 @@ LuaScripting::get_factory_bytecode (const std::string& script, const std::string if (lua_factory.isFunction()) { return (lua_dump(lua_factory)).cast (); } - } catch (luabridge::LuaException const& e) { } + } catch (...) { } return ""; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 324e235c72..785977dc75 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -5513,7 +5513,7 @@ Session::registered_lua_functions () if (!i.key ().isString ()) { assert(0); continue; } rv.push_back (i.key ().cast ()); } - } catch (luabridge::LuaException const& e) { } + } catch (...) { } return rv; } @@ -5529,7 +5529,7 @@ Session::try_run_lua (pframes_t nframes) if (_n_lua_scripts == 0) return; Glib::Threads::Mutex::Lock tm (lua_lock, Glib::Threads::TRY_LOCK); if (tm.locked ()) { - try { (*_lua_run)(nframes); } catch (luabridge::LuaException const& e) { } + try { (*_lua_run)(nframes); } catch (...) { } lua.collect_garbage_step (); } } @@ -5661,7 +5661,12 @@ Session::setup_lua () _lua_cleanup = new luabridge::LuaRef(lua_sess["cleanup"]); } catch (luabridge::LuaException const& e) { fatal << string_compose (_("programming error: %1"), - X_("Failed to setup Lua interpreter")) + std::string ("Failed to setup session Lua interpreter") + e.what ()) + << endmsg; + abort(); /*NOTREACHED*/ + } catch (...) { + fatal << string_compose (_("programming error: %1"), + X_("Failed to setup session Lua interpreter")) << endmsg; abort(); /*NOTREACHED*/ } @@ -5687,6 +5692,11 @@ Session::scripts_changed () } _n_lua_scripts = cnt; } catch (luabridge::LuaException const& e) { + fatal << string_compose (_("programming error: %1"), + std::string ("Indexing Lua Session Scripts failed.") + e.what ()) + << endmsg; + abort(); /*NOTREACHED*/ + } catch (...) { fatal << string_compose (_("programming error: %1"), X_("Indexing Lua Session Scripts failed.")) << endmsg; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 205781b00c..0a1eb2ace6 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1683,7 +1683,7 @@ Session::set_state (const XMLNode& node, int version) (*_lua_load)(std::string ((const char*)buf, size)); } catch (luabridge::LuaException const& e) { cerr << "LuaException:" << e.what () << endl; - } + } catch (...) { } g_free (buf); } } -- 2.30.2