Patch 7.4.1791
Problem: Channel could be garbage collected too early.
Solution: Don't free a channel or remove it from a job when it is still
useful.
Files: src/channel.c
*** ../vim-7.4.1790/src/channel.c 2016-04-26 19:01:00.957118797 +0200
--- src/channel.c 2016-04-26 20:26:56.507094064 +0200
***************
*** 439,445 ****
channel_T *ch;
for (ch = first_channel; ch != NULL; ch = ch->ch_next)
! if ((ch->ch_copyID & mask) != (copyID & mask))
{
/* Free the channel and ordinary items it contains, but don't
* recurse into Lists, Dictionaries etc. */
--- 439,446 ----
channel_T *ch;
for (ch = first_channel; ch != NULL; ch = ch->ch_next)
! if (!channel_still_useful(ch)
! && (ch->ch_copyID & mask) != (copyID & mask))
{
/* Free the channel and ordinary items it contains, but don't
* recurse into Lists, Dictionaries etc. */
***************
*** 458,464 ****
for (ch = first_channel; ch != NULL; ch = ch_next)
{
ch_next = ch->ch_next;
! if ((ch->ch_copyID & mask) != (copyID & mask))
{
/* Free the channel struct itself. */
channel_free_channel(ch);
--- 459,466 ----
for (ch = first_channel; ch != NULL; ch = ch_next)
{
ch_next = ch->ch_next;
! if (!channel_still_useful(ch)
! && (ch->ch_copyID & mask) != (copyID & mask))
{
/* Free the channel struct itself. */
channel_free_channel(ch);
***************
*** 4079,4091 ****
/*
* Return TRUE if the job should not be freed yet. Do not free the job when
! * it has not ended yet and there is a "stoponexit" flag or an exit callback.
*/
static int
job_still_useful(job_T *job)
{
return job->jv_status == JOB_STARTED
! && (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL);
}
void
--- 4081,4096 ----
/*
* Return TRUE if the job should not be freed yet. Do not free the job when
! * it has not ended yet and there is a "stoponexit" flag, an exit callback
! * or when the associated channel will do something with the job output.
*/
static int
job_still_useful(job_T *job)
{
return job->jv_status == JOB_STARTED
! && (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL
! || (job->jv_channel != NULL
! && channel_still_useful(job->jv_channel)));
}
void
***************
*** 4099,4108 ****
{
job_free(job);
}
! else if (job->jv_channel != NULL)
{
/* Do remove the link to the channel, otherwise it hangs
* around until Vim exits. See job_free() for refcount. */
job->jv_channel->ch_job = NULL;
channel_unref(job->jv_channel);
job->jv_channel = NULL;
--- 4104,4115 ----
{
job_free(job);
}
! else if (job->jv_channel != NULL
! && !channel_still_useful(job->jv_channel))
{
/* Do remove the link to the channel, otherwise it hangs
* around until Vim exits. See job_free() for refcount. */
+ ch_log(job->jv_channel, "detaching channel from job");
job->jv_channel->ch_job = NULL;
channel_unref(job->jv_channel);
job->jv_channel = NULL;
*** ../vim-7.4.1790/src/version.c 2016-04-26 19:42:39.206426710 +0200
--- src/version.c 2016-04-26 20:25:56.623797395 +0200
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 1791,
/**/
--
[Autumn changed into Winter ... Winter changed into Spring ... Spring
changed back into Autumn and Autumn gave Winter and Spring a miss and
went straight on into Summer ... Until one day ...]
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// 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.