From 16ca7ceaed7515c7dffe8f512940f31c103ee8d0 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 14 Jun 2025 11:44:41 +0200 Subject: [PATCH] fix(build): disable problematic marktree assert in RelWithDebInfo builds Workaround (not a fix) for #27196 and for #33067 Asserts are meant to apply to debug builds but not release builds for users. However the intermediate RelWithDebInfo build type is quite often used by end users, so we might want to disable certain problematic asserts there, while still preserving them in Debug mode for CI. --- CMakeLists.txt | 4 ++-- src/nvim/decoration.c | 3 +++ src/nvim/marktree.c | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f6c38b934..491f6c525a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,8 +151,8 @@ set(NVIM_API_PRERELEASE false) # We _want_ assertions in RelWithDebInfo build-type. if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) - string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - string(REPLACE "/DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + string(REPLACE "-DNDEBUG" "-DRELDEBUG" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + string(REPLACE "/DNDEBUG" "/DRELDEBUG" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE " " " " CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") # Remove duplicate whitespace endif() diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 8dbdb7eddc..68ee11d02e 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -1068,7 +1068,10 @@ void buf_signcols_count_range(buf_T *buf, int row1, int row2, int add, TriState int prevwidth = MIN(SIGN_SHOW_MAX, count[i] - add); if (clear != kNone && prevwidth > 0) { buf->b_signcols.count[prevwidth - 1]--; +#ifndef RELDEBUG + // TODO(bfredl): correct marktree splicing so that this doesn't fail assert(buf->b_signcols.count[prevwidth - 1] >= 0); +#endif } int width = MIN(SIGN_SHOW_MAX, count[i]); if (clear != kTrue && width > 0) { diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index e2b4296fcd..2902c31f68 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -372,7 +372,13 @@ static void unintersect_node(MarkTree *b, MTNode *x, uint64_t id, bool strict) } } if (strict) { +#ifndef RELDEBUG + // TODO(bfredl): This assert has been seen to fail for end users + // using RelWithDebInfo builds. While indicating an invalid state for + // the marktree, this error doesn't need to be fatal. The assert still + // needs to present in Debug builds to be able to detect regressions in tests. assert(seen); +#endif } if (seen) {