From: Remi Gacogne Date: Thu, 5 Jun 2025 13:55:29 +0000 (+0200) Subject: rec: Fix stack-use-after-scope reported by ASAN X-Git-Tag: dnsdist-2.0.0-beta1~38^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70d8016c29a80fb1502193400def05a0cd186eec;p=thirdparty%2Fpdns.git rec: Fix stack-use-after-scope reported by ASAN Technically we are indeed using a stack that is no longer the active one, because we just switched to a different context, but since the previous stack still exists that I do not believe it is a real issue. After this commit we access the previous stack before notifying ASAN that the stack switch is finished, so we are still allowed to do that. Note that clang 19 ASAN is fine with both behaviour, but GCC 14 and 15 ASAN aren't. Signed-off-by: Remi Gacogne --- diff --git a/pdns/recursordist/mtasker_context.cc b/pdns/recursordist/mtasker_context.cc index b162d68771..d2d9157a86 100644 --- a/pdns/recursordist/mtasker_context.cc +++ b/pdns/recursordist/mtasker_context.cc @@ -160,11 +160,11 @@ extern "C" *ptr = res.fctx; } #endif + auto start = std::move(*work); notifyStackSwitchDone(); args = nullptr; try { - auto start = std::move(*work); start(); } catch (...) {