From: Vladimír Čunát Date: Mon, 3 Aug 2026 11:57:51 +0000 (+0200) Subject: serve_stale: avoid SIGSEGV from a LuaJIT bug X-Git-Tag: v6.4.2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=710efa0f775efbbdc91656e35a5a31a7ec90ec23;p=thirdparty%2Fknot-resolver.git serve_stale: avoid SIGSEGV from a LuaJIT bug The debugging and fix was really submitted by David Komárek from Whalebone.io --- diff --git a/NEWS b/NEWS index 08ac8dfae..d2b8aa2d2 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ Knot Resolver 6.4.2 (2026-08-dd) Bugfixes -------- - cache: avoid excessive logging introduced in the last release (!1869) +- /options/serve-stale: avoid SIGSEGV from a LuaJIT bug (#957) Knot Resolver 6.4.1 (2026-07-22) diff --git a/modules/serve_stale/serve_stale.lua b/modules/serve_stale/serve_stale.lua index d1b18f90e..73362a9a7 100644 --- a/modules/serve_stale/serve_stale.lua +++ b/modules/serve_stale/serve_stale.lua @@ -7,15 +7,17 @@ local ffi = require('ffi') -- approximately at multiples of KR_CONN_RTT_MAX. M.timeout = 3*sec -M.callback = ffi.cast("kr_stale_cb", - function (ttl) --, name, type, qry) - --log_debug(ffi.C.SRVSTALE, ' => called back with TTL: ' .. tostring(ttl)) - if ttl + 3600 * 24 > 0 then -- at most one day stale - return 1 - else - return -1 - end - end) +local function stale_cb(ttl) --, name, type, qry) + --log_debug(ffi.C.SRVSTALE, ' => called back with TTL: ' .. tostring(ttl)) + if ttl + 3600 * 24 > 0 then -- at most one day stale + return 1 + else + return -1 + end +end +-- Work around a LuaJIT bug: https://github.com/LuaJIT/LuaJIT/issues/1498 +jit.off(stale_cb) +M.callback = ffi.cast("kr_stale_cb", stale_cb) M.layer = { produce = function (state, req)