From: Vladimír Čunát Date: Wed, 10 Feb 2021 11:56:14 +0000 (+0100) Subject: modules/{http,watchdog}: fix stability problems X-Git-Tag: v5.3.0~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c07676547c037a721e5c842453adc4b8dd43c8ae;p=thirdparty%2Fknot-resolver.git modules/{http,watchdog}: fix stability problems 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/* --- diff --git a/modules/http/http_trace.lua b/modules/http/http_trace.lua index a9764d5a1..123cd529b 100644 --- a/modules/http/http_trace.lua +++ b/modules/http/http_trace.lua @@ -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() diff --git a/modules/watchdog/watchdog.lua b/modules/watchdog/watchdog.lua index b7e162b9d..710b8a8c4 100644 --- a/modules/watchdog/watchdog.lua +++ b/modules/watchdog/watchdog.lua @@ -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)