]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/{http,watchdog}: fix stability problems
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 10 Feb 2021 11:56:14 +0000 (12:56 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 11 Feb 2021 10:00:52 +0000 (11:00 +0100)
As first noted in commit d1a229ae9, in some cases we do call chains that
are not supported for JIT in LuaJIT.

I'm not 100% sure all of these are needed to comply, but the functions
here are really small and probably not to be that heavily used,
so I don't think it will be costly to interpret them
(and avoiding crashes is more important).

In my tests this fixed occasional crashes when using http://*/trace/*

modules/http/http_trace.lua
modules/watchdog/watchdog.lua

index a9764d5a1e82981e987b872f249684b8bcaf9bd7..123cd529bfbef94d1f22d070a927ccea484e5594 100644 (file)
@@ -23,6 +23,7 @@ local function serve_trace(h, _)
        -- Create logging handler callback
        local buffer = {}
        local buffer_log_cb = ffi.cast('trace_log_f', function (_, msg)
+               jit.off(true, true) -- JIT for (C -> lua)^2 nesting isn't allowed
                table.insert(buffer, ffi.string(msg))
        end)
 
@@ -32,6 +33,7 @@ local function serve_trace(h, _)
        local cond = condition.new()
        local waiting, done = false, false
        local finish_cb = ffi.cast('trace_callback_f', function (req)
+               jit.off(true, true) -- JIT for (C -> lua)^2 nesting isn't allowed
                table.insert(buffer, req:selected_tostring())
                if waiting then
                        cond:signal()
index b7e162b9db1ea52ef14b58b7daa96d9ebb30dcc0..710b8a8c4cfd34d72c1ba91a0db2f09d4be00e53 100644 (file)
@@ -23,6 +23,7 @@ end
 local function add_tracer(logbuf)
        return function (req)
                local function qrylogger(_, msg)
+                       jit.off(true, true) -- JIT for (C -> lua)^2 nesting isn't allowed
                        table.insert(logbuf, ffi.string(msg))
                end
                req.trace_log = ffi.cast('trace_log_f', qrylogger)