From 33dbd3c4465b81812be22199fb0446e7e47dd47a Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Sat, 16 Nov 2024 22:50:24 +0100 Subject: [PATCH 1/2] chore: avoid stack overflow in debug tests --- src/include/lean/lean.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/lean/lean.h b/src/include/lean/lean.h index 51e8984b8324..41e5b4c9ec8b 100644 --- a/src/include/lean/lean.h +++ b/src/include/lean/lean.h @@ -37,7 +37,13 @@ extern "C" { #if defined(__GNUC__) || defined(__clang__) #define LEAN_UNLIKELY(x) (__builtin_expect((x), 0)) #define LEAN_LIKELY(x) (__builtin_expect((x), 1)) + +// We have observed stack frame increases from forced inlining overflowing the stack in debug builds, +// let's leave the decision to the compiler in that case +#ifdef NDEBUG #define LEAN_ALWAYS_INLINE __attribute__((always_inline)) +#endif + #else #define LEAN_UNLIKELY(x) (x) #define LEAN_LIKELY(x) (x) From c6a41e7b52981164e5962afba0ff57f8c508b3ab Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Sun, 17 Nov 2024 14:40:02 +0100 Subject: [PATCH 2/2] fix --- src/include/lean/lean.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/lean/lean.h b/src/include/lean/lean.h index 41e5b4c9ec8b..1ad7aac78389 100644 --- a/src/include/lean/lean.h +++ b/src/include/lean/lean.h @@ -38,10 +38,12 @@ extern "C" { #define LEAN_UNLIKELY(x) (__builtin_expect((x), 0)) #define LEAN_LIKELY(x) (__builtin_expect((x), 1)) -// We have observed stack frame increases from forced inlining overflowing the stack in debug builds, -// let's leave the decision to the compiler in that case #ifdef NDEBUG #define LEAN_ALWAYS_INLINE __attribute__((always_inline)) +#else +// We have observed stack frame increases from forced inlining overflowing the stack in debug builds, +// let's leave the decision to the compiler in that case +#define LEAN_ALWAYS_INLINE #endif #else