Lua may call C++ functions with throw. Catch them
authorRobin Gareus <robin@gareus.org>
Fri, 18 Aug 2017 23:05:18 +0000 (01:05 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 18 Aug 2017 23:06:44 +0000 (01:06 +0200)
libs/ardour/luaproc.cc
libs/ardour/luascripting.cc
libs/ardour/session.cc
libs/ardour/session_state.cc

index 6581743771daf0cc38597068c7433ee0bc9abd46..c1fd455cdff50f1eca0a7691d0138fef5149dafd 100644 (file)
@@ -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 ();
index e2fc9d49f109a5c2572cf7648e771c6ed3430dc0..a63dc9ea489f91ed80a34b279335d55b13e18627 100644 (file)
@@ -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<std::string> ();
                }
-       } catch (luabridge::LuaException const& e) { }
+       } catch (...) { }
        return "";
 }
 
index 324e235c72eaaf4406ecca55483f61f92ce7d94b..785977dc75da943031e8b1b431b3d13ef16dd455 100644 (file)
@@ -5513,7 +5513,7 @@ Session::registered_lua_functions ()
                        if (!i.key ().isString ()) { assert(0); continue; }
                        rv.push_back (i.key ().cast<std::string> ());
                }
-       } 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;
index 205781b00cec38b5a9b109ea818bc1c7476fc9ce..0a1eb2ace689bce14d487b60b48bf7d5f8081f70 100644 (file)
@@ -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);
                }
        }