]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Fix stack-use-after-scope reported by ASAN
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 5 Jun 2025 13:55:29 +0000 (15:55 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 5 Jun 2025 13:59:05 +0000 (15:59 +0200)
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 <remi.gacogne@powerdns.com>
pdns/recursordist/mtasker_context.cc

index b162d6877112682b591b181c9952fe23d12381c4..d2d9157a8667c5e11ddb5aad7c1e80d0c411120f 100644 (file)
@@ -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 (...) {