From 4c4f5cccaa0082317b9dda16db1e84222f5f24eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Wed, 8 Apr 2020 14:27:33 +0200 Subject: [PATCH] Work around an MSVC bug The assembly code generated by MSVC for at least some signed comparisons involving atomic variables incorrectly uses unsigned conditional jumps instead of signed ones. In particular, the checks in isc_log_wouldlog() are affected in a way which breaks logging on Windows and thus also all system tests involving a named instance. Work around the issue by assigning the values returned by atomic_load_acquire() calls in isc_log_wouldlog() to local variables before performing comparisons. --- lib/isc/log.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/isc/log.c b/lib/isc/log.c index 4b7d877f3a..fcf387e94e 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -1454,13 +1454,15 @@ isc_log_wouldlog(isc_log_t *lctx, int level) { return (false); } - if (level <= atomic_load_acquire(&lctx->highest_level)) { + int highest_level = atomic_load_acquire(&lctx->highest_level); + if (level <= highest_level) { return (true); } - if (atomic_load_acquire(&lctx->dynamic) && - level <= atomic_load_acquire(&lctx->debug_level)) - { - return (true); + if (atomic_load_acquire(&lctx->dynamic)) { + int debug_level = atomic_load_acquire(&lctx->debug_level); + if (level <= debug_level) { + return (true); + } } return (false);