From 01d9286fbe98fe6b37686681f580d7efa500a63a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 16 Feb 2016 09:44:51 +0100 Subject: [PATCH] dnsdist: Lock the Lua context before executing a LuaAction Otherwise the stack of the Lua context might get corrupted whenever another Lua function (blockfilter, policy, maintenance or another LuaAction) is simultaneously called from another thread. We might be able to use a separate execution stack via createThread()/lua_newthread(), but if I understand correctly how it works, we would need to be sure that the Lua function called does not access the global state at all, which is probably too restrictive. This should fix #3374, #3375, #3376, #3377, #3378, #3379, #3383, and hopefully the random travis failures in our regression tests. --- pdns/dnsdist-lua.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index d83f586647..32fc832821 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -22,6 +22,7 @@ public: Action operator()(DNSQuestion* dq, string* ruleresult) const override { + std::lock_guard lock(g_luamutex); auto ret = d_func(dq); if(ruleresult) *ruleresult=std::get<1>(ret); -- 2.47.2