Yukihiro Nakadaira wrote:

> On Sat, Feb 13, 2016 at 8:20 PM, Yukihiro Nakadaira <
> [email protected]> wrote:
> 
> > On Sat, Feb 13, 2016 at 5:36 AM, Christian Brabandt <[email protected]>
> > wrote:
> >
> >> Hi Bram!
> >>
> >> On Fr, 12 Feb 2016, Bram Moolenaar wrote:
> >>
> >> >
> >> > Patch 7.4.1306
> >> > Problem:    Job control doesn't work well on MS-Windows.
> >> > Solution:   Various fixes. (Ken Takata, Ozaki Kiichi , Yukihiro
> >> Nakadaira,
> >> >             Yasuhiro Matsumoto)
> >> > Files:      src/Make_mvc.mak, src/eval.c, src/os_unix.c, src/os_win32.c,
> >> >             src/proto/os_unix.pro, src/proto/os_win32.pro,
> >> src/structs.h
> >>
> >> This patch breaks appveyor (I assume the test_channel test)
> >> https://ci.appveyor.com/project/chrisbra/vim/build/602
> >>
> >
> > Crash is caused by WM_NETBEANS message issued by WSAAsyncSelect().
> >
> >
> > let h = job_start('py testdir/test_channel.py')
> > let port = []
> > sleep 1
> > let port = readfile('Xportnr')
> > call delete('Xportnr')
> > let c = ch_open('localhost:' . port[0])
> >
> > echo ch_sendexpr(c, 'hello!')
> > " => request(hello!)
> > " <= response(got it)     (Raise WM_NETBEANS and it remains in message
> > queue)
> >
> > call job_stop(h)
> > " Remote socket is closed.
> >
> > ":sleep 1
> > " Catch WM_NETBEANS.  But socket is already closed.
> > " E896: read from channel: A non-blocking socket operation could not be
> > completed immediately.
> >
> > for i in range(1000)
> >   try
> >     throw "err"
> >   catch
> >     " When WM_NETBEANS is catched in ex_catch(), it breaks memory.
> >     "   ex_catch():
> >     "   1585                     caught = vim_regexec_nl(&regmatch,
> > current_exception->value,
> >     "   1586                             (colnr_T)0);
> >     " gui_mch_update() is executed in vim_regexec_nl().  And error is
> > thrown.
> >     "   read_channel():
> >     "   1262             PERROR(_("E896: read from channel"));
> >     " And current_exception is free()ed.
> >     "   cause_errthrow():
> >     "   228         discard_current_exception();
> >     " And the freed memory is used later.
> >   endtry
> > endfor
> >
> 
> 
> Maybe this patch fix this problem.
> Error is still shown.  But it might implies script or server bug.
> 
> diff --git a/src/gui_w48.c b/src/gui_w48.c
> index 7789ef2..f2d2091 100644
> --- a/src/gui_w48.c
> +++ b/src/gui_w48.c
> @@ -1783,7 +1783,14 @@ process_message(void)
>   int channel_idx = channel_socket2idx((sock_T)msg.wParam);
> 
>   if (channel_idx >= 0)
> +        {
> +     int suppress_errthrow_save;
> +
> +     suppress_errthrow_save = suppress_errthrow;
> +     suppress_errthrow = TRUE;
>       channel_read(channel_idx);
> +     suppress_errthrow = suppress_errthrow_save;
> +        }
>   return;
>      }
>  #endif

Thanks for the explanation.  Doing this low-level exception stuff here
doesn't seem right.  Perhaps this works:

        if (channel_idx >= 0)
        {
            /* Disable error messages, they can mess up the display and throw
             * an exception. */
            ++emsg_off;
            channel_read(channel_idx, FALSE, "process_message");
            --emsg_off;
        }

I'll try it out.  Now that the log is implement that can be used to find
communication errors, instead of displaying them.  That can happen at
any time and interrupt what the user was doing.

Hmm, I can't seem to reproduce the problem anymore.  The changes I made
to support pipes may have fixed the problem as a side effect.

You mention "freed memory is used later", is there another problem that
should be fixed?

-- 
Marriage isn't a word.  It's a sentence.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui