]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
serve_stale: avoid SIGSEGV from a LuaJIT bug docs-serve-stale-3dxyiy/deployments/9718 1878/head
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 Aug 2026 11:57:51 +0000 (13:57 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 Aug 2026 12:12:33 +0000 (14:12 +0200)
The debugging and fix was really submitted by
David Komárek from Whalebone.io

NEWS
modules/serve_stale/serve_stale.lua

diff --git a/NEWS b/NEWS
index 08ac8dfaedd500b7e9d6ac4eec8924d55558b5c3..d2b8aa2d2e6cd38ce6175560fc2965ced63b896d 100644 (file)
--- 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)
index d1b18f90e3f4a88701f07051e15302c3d8f6317f..73362a9a7da3c5cf7c3a32f7f562d6222992d0b1 100644 (file)
@@ -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)