Hi Edd,

with my configuration and plugins, I have a crash with neovim-0.9.4 on 
current/amd64 (kernel GENERIC.MP#1523) when I close the editor.

Coredump analysis:

$ gdb /usr/local/bin/nvim /tmp/nvim.core
(...)
(gdb) bt
#0  thrkill () at /tmp/-:2
#1  0x61bb7d265d1d2f53 in ?? ()
#2  0x000000cf81f8c092 in _libc_abort () at /usr/src/lib/libc/stdlib/abort.c:51
#3  0x000000cf81f44e06 in _libc___assert2 (file=Variable "file" is not 
available.) at /usr/src/lib/libc/gen/assert.c:52
#4  0x000000cfbc8fc7ef in uv_close () from /usr/local/lib/libuv.so.4.1
#5  0x000000ccfd64339a in write_cb.llvm.15707295189128387235 () from 
/usr/local/bin/nvim
#6  0x000000cfbc908b3e in uv__write_callbacks () from 
/usr/local/lib/libuv.so.4.1
#7  0x000000cfbc908988 in uv__stream_destroy () from /usr/local/lib/libuv.so.4.1
#8  0x000000cfbc8fcdeb in uv_run () from /usr/local/lib/libuv.so.4.1
#9  0x000000ccfd63e087 in loop_close () from /usr/local/bin/nvim
#10 0x000000ccfd5181b5 in os_exit () from /usr/local/bin/nvim
#11 0x000000ccfd518151 in getout () from /usr/local/bin/nvim
#12 0x000000ccfd663180 in ex_quit.llvm.18128057263189303951 () from 
/usr/local/bin/nvim
#13 0x000000ccfd659fd0 in execute_cmd0 () from /usr/local/bin/nvim
#14 0x000000ccfd654fe1 in do_cmdline () from /usr/local/bin/nvim
#15 0x000000ccfd74332e in nv_colon.llvm.1549626131334729254 () from 
/usr/local/bin/nvim
#16 0x000000ccfd73efbc in normal_execute.llvm.1549626131334729254 () from 
/usr/local/bin/nvim
#17 0x000000ccfd836f01 in state_enter () from /usr/local/bin/nvim
#18 0x000000ccfd5173e5 in main () from /usr/local/bin/nvim

This backtrace looks like this one described in issue#25086 
https://github.com/neovim/neovim/issues/25086
=> crash using 'uv_close'.

I added the fix included in this issue, rebuild => no more crash with Neovim :)

Please, could you test and commit my patch if OK for you ?

Laurent

Index: Makefile
===================================================================
RCS file: /cvs/ports/editors/neovim/Makefile,v
retrieving revision 1.40
diff -u -p -r1.40 Makefile
--- Makefile	13 Oct 2023 19:30:15 -0000	1.40
+++ Makefile	17 Dec 2023 11:10:04 -0000
@@ -13,6 +13,8 @@ COMMENT =	continuation and extension of 
 
 DIST_TUPLE =	github neovim neovim v0.9.4 .
 
+REVISION =	0
+
 # embedded luajit
 USE_NOBTCFI =	Yes
 
Index: patches/patch-src_nvim_event_stream_c
===================================================================
RCS file: patches/patch-src_nvim_event_stream_c
diff -N patches/patch-src_nvim_event_stream_c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_nvim_event_stream_c	17 Dec 2023 11:10:04 -0000
@@ -0,0 +1,31 @@
+Fix crash for version 0.9.4 on uv_close
+See https://github.com/neovim/neovim/issues/25086
+
+Index: src/nvim/event/stream.c
+--- src/nvim/event/stream.c.orig
++++ src/nvim/event/stream.c
+@@ -133,15 +133,22 @@ void stream_may_close(Stream *stream)
+ void stream_close_handle(Stream *stream)
+   FUNC_ATTR_NONNULL_ALL
+ {
++  uv_handle_t *handle = NULL;
+   if (stream->uvstream) {
+     if (uv_stream_get_write_queue_size(stream->uvstream) > 0) {
+       WLOG("closed Stream (%p) with %zu unwritten bytes",
+            (void *)stream,
+            uv_stream_get_write_queue_size(stream->uvstream));
+     }
+-    uv_close((uv_handle_t *)stream->uvstream, close_cb);
++    handle = (uv_handle_t *)stream->uvstream;
+   } else {
+-    uv_close((uv_handle_t *)&stream->uv.idle, close_cb);
++    handle = (uv_handle_t *)&stream->uv.idle;
++  }
++
++  assert(handle != NULL);
++
++  if (!uv_is_closing(handle)) {
++    uv_close(handle, close_cb);
+   }
+ }
+ 

Reply via email to