Monday, January 23, 2017

Re: Channel callbacks randomly fail to fire in Vim for win32

Now I have these logs captured using ch_logfile(...):

https://gist.github.com/anonymous/d9b00634422a69b7ea3729ca6ac21b40

The first received message failed but the second succeeded. I verified
both messages, concatenated the fragments manually and parsed them
with some trivial Python code. they're all legit JSON strings, and
they are actually the same except the message IDs.

Having these info, I think the root cause lies in the channel (or
JSON?) implementation inside Vim.

I will keep looking into it, but I would be grateful if there's
someone familiar with the channel implementation that can help me out.

Thanks!

2017-01-23 13:04 GMT+08:00 Kay Zheng <l04m33@gmail.com>:
> I made the callback failure happen on my Linux system too. Turned out
> it has something to do with the message length (or the time needed to
> receive the whole message?) Longer messages tend to fail more often.
>
> But I couldn't find a fixed length to trigger this problem. In my
> set-up, messages of around 4k bytes were very likely to fail, and
> messages of around 40k bytes would definitely fail.
>
> I tried setting the 'drop' option of ch_open(...) to 'never', but it
> makes no difference regarding this problem.
>
> I'm using a self-compiled Vim from the official source repo on GitHub,
> commit c81299684b2b9045e56525d3da3f45e8440fbf0d.
>
> Regards,
>
> Kay Z.
>
> 2017-01-18 17:39 GMT+08:00 Kay Zheng <l04m33@gmail.com>:
>> Hi.
>>
>> I've been working on a Vim plugin using the channel APIs. When testing
>> the plugin on Windows (Windows 7 Pro. SP1 32-bit), one of my channel
>> callbacks failed to fire sometimes.
>>
>> There was no error or anything. It looked like the message passing
>> through the channel just went missing. I used Wireshark to capture the
>> packets, and it turned out the message which was supposed to trigger
>> the callback did go through the sockets, but Vim just won't call my
>> callback.
>>
>> I tried ch_logfile(...). But with the logging enabled, I could not
>> reproduce the problem anymore. Yuck!
>>
>> I've been reviewing and testing my code, hoping to find something
>> relevant, but the code worked fine on my other system (Fedora Linux).
>>
>> The difficulty here is that the callback failure happened randomly.
>> The code involved was not trivial and I couldn't find a reliable way
>> to reproduce the problem. So I turn to the nice Vim people here for
>> suggestions.
>>
>> I'm using the latest win32 Vim release from vim.org: 8.0 with patches
>> 1-69 (32-bit GUI version with OLE support).
>>
>> And the code involved is on Github:
>> https://github.com/l04m33/vlime/blob/00f0f2505597ee5e6f3ff0a268e303b0cfeb2605/vim/plugin/vlime.vim#L45
>>
>> The callback function on line 45 is the one failed to fire. I used a
>> "chaining" mechanism to call those callbacks and save some typing.
>>
>> Any suggestions would be greatly appreciated.
>>
>> Regards.
>>
>> Kay Z.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment