From 33b6b0bfe5bc47dfa19b327310a6827206078a87 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Wed, 20 May 2026 14:13:41 +0200 Subject: [PATCH] fix(messages): avoid recursive rtp build due to msg_show #39888 Problem: If there are pending messages when starting to build the runtime search path, a msg_show callback may invoke runtime_search_path_validate() recursively. Solution: Avoid msg_show callback by ensuring messages are flushed. (cherry picked from commit 53da0c5060b821cfc2948a2c2ac0c6662a1c26d5) --- src/nvim/runtime.c | 1 + test/functional/core/startup_spec.lua | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 47e1feface..e9202150e6 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -933,6 +933,7 @@ void runtime_search_path_validate(void) } if (!runtime_search_path_valid) { if (!runtime_search_path_ref) { + msg_ext_ui_flush(); // avoid recursion due to UI callback runtime_search_path_free(runtime_search_path); } runtime_search_path = runtime_search_path_build(); diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 55af3bdc4c..0c7ea32fd8 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -1794,6 +1794,18 @@ describe('runtime:', function() command('edit FTDETECT') eq('SsABab', eval('g:aseq')) end) + + it('no crash for recursive search_path build #39815', function() + clear() + local screen = Screen.new() + fn.jobstart({ + nvim_prog, + '--clean', + '+lua require("vim._core.ui2").enable()', + '+set rtp+=$FOO | set syntax', + }, { term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }) + screen:expect({ any = 'syntax', none = 'Process exited 1' }) + end) end) describe('user session', function()