Patch 8.2.0452

46 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 26, 2020, 11:05:41 AM3/26/20
to vim...@googlegroups.com

Patch 8.2.0452
Problem: channel_parse_messages() fails when called recursively.
Solution: Return for a recursive call. (closes #5835)
Files: src/channel.c


*** ../vim-8.2.0451/src/channel.c 2020-03-24 20:35:14.741080390 +0100
--- src/channel.c 2020-03-26 15:56:02.939711511 +0100
***************
*** 4428,4441 ****
int ret = FALSE;
int r;
ch_part_T part = PART_SOCK;
#ifdef ELAPSED_FUNC
elapsed_T start_tv;
-
- ELAPSED_INIT(start_tv);
#endif

++safe_to_invoke_callback;

// Only do this message when another message was given, otherwise we get
// lots of them.
if ((did_repeated_msg & REPEATED_MSG_LOOKING) == 0)
--- 4428,4449 ----
int ret = FALSE;
int r;
ch_part_T part = PART_SOCK;
+ static int recursive = FALSE;
#ifdef ELAPSED_FUNC
elapsed_T start_tv;
#endif

+ // The code below may invoke callbacks, which might call us back.
+ // That doesn't work well, just return without doing anything.
+ if (recursive)
+ return FALSE;
+ recursive = TRUE;
++safe_to_invoke_callback;

+ #ifdef ELAPSED_FUNC
+ ELAPSED_INIT(start_tv);
+ #endif
+
// Only do this message when another message was given, otherwise we get
// lots of them.
if ((did_repeated_msg & REPEATED_MSG_LOOKING) == 0)
***************
*** 4513,4518 ****
--- 4521,4527 ----
}

--safe_to_invoke_callback;
+ recursive = FALSE;

return ret;
}
*** ../vim-8.2.0451/src/version.c 2020-03-26 15:39:50.223238189 +0100
--- src/version.c 2020-03-26 15:56:59.759509505 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 452,
/**/

--
Windows
M!uqoms

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Paul Jolly

unread,
Mar 27, 2020, 5:22:18 PM3/27/20
to Vim Dev Mailing List
This change has broken govim which relies on recursive calls working. I'll submit an issue with further details tomorrow

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/202003261505.02QF5V0c000459%40masaka.moolenaar.net.

Bram Moolenaar

unread,
Mar 28, 2020, 9:54:00 AM3/28/20
to vim...@googlegroups.com, Paul Jolly

Paul Jolly wrote:

> This change has broken govim which relies on recursive calls working. I'll
> submit an issue with further details tomorrow

It would be good to know why the recursion is needed. One thing we can
do is to only disallow closing channels when called recursively.


--
The early bird gets the worm. If you want something else for
breakfast, get up later.

Paul Jolly

unread,
Mar 28, 2020, 10:09:50 AM3/28/20
to Bram Moolenaar, Vim Dev Mailing List
> It would be good to know why the recursion is needed.

The canonical example is an autocommand handler in a remote plugin
that performs some actions that trigger another autocommand that also
has a remote handler.

But we have many others.

> One thing we can
> do is to only disallow closing channels when called recursively.

This would work. We only ever close the channel from Vim on exit, and
if we wanted to close if prior to that it would not be via a remote
function call, it would be via pure VimScript.

Bram Moolenaar

unread,
Mar 28, 2020, 1:07:54 PM3/28/20
to vim...@googlegroups.com, Paul Jolly
OK, let me implement this now: patch 8.2.0466.
Still would be good to have a test that would fail before this.

--
LAUNCELOT: I am, sir. I am a Knight of King Arthur.
FATHER: 'Mm ... very nice castle, Camelot ... very good pig country....
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Paul Jolly

unread,
Mar 28, 2020, 2:18:01 PM3/28/20
to Bram Moolenaar, Vim Dev Mailing List
Thanks - per my response to the patch that fixes things.
Reply all
Reply to author
Forward
0 new messages