From b080fcd3cd14aa79e8f116962e5fa6826e9b5026 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 12 Aug 2025 19:01:59 -0400 Subject: [PATCH] ZJIT: Fix assert failure on JIT combo build Previously, when `./configure --enable-yjit=dev --enable-zjit` JIT_DESCRIPTION was defined to be "ZJIT", but when running with `--yjit`, ruby_set_yjit_description() calls `define_ruby_description("+YJIT dev")`, which is longer than the following assertion expects: RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(JIT_DESCRIPTION)); Use the concatenation of the two strings -- the contents of the string is never used. Minimize the scope of the macro, too. --- version.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/version.c b/version.c index 243f00b38c..d634755efd 100644 --- a/version.c +++ b/version.c @@ -72,11 +72,6 @@ const int ruby_api_version[] = { #else #define ZJIT_DESCRIPTION " +ZJIT" #endif -#if USE_ZJIT -#define JIT_DESCRIPTION ZJIT_DESCRIPTION -#else -#define JIT_DESCRIPTION YJIT_DESCRIPTION -#endif #if USE_MODULAR_GC #define GC_DESCRIPTION " +GC" #else @@ -207,6 +202,8 @@ rb_ruby_default_parser_set(ruby_default_parser_enum parser) static void define_ruby_description(const char *const jit_opt) { +#define JIT_DESCRIPTION YJIT_DESCRIPTION ZJIT_DESCRIPTION + static char desc[ sizeof(ruby_description) + rb_strlen_lit(JIT_DESCRIPTION) @@ -248,6 +245,7 @@ define_ruby_description(const char *const jit_opt) * The full ruby version string, like ruby -v prints */ rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description); +#undef JIT_DESCRIPTION } void