1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0960
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0960
Problem: When using ConPTY garbage collection has undefined behavior.
Solution: Free the channel in a better way. (Nobuhiro Takasaki, closes #4020)
Files: src/channel.c
*** ../vim-8.1.0959/src/channel.c 2019-02-17 17:44:36.199875566 +0100
--- src/channel.c 2019-02-20 22:44:26.019845642 +0100
***************
*** 191,197 ****
static int did_log_msg = TRUE;
! #ifndef PROTO /* prototype is in vim.h */
void
ch_log(channel_T *ch, const char *fmt, ...)
{
--- 191,197 ----
static int did_log_msg = TRUE;
! #ifndef PROTO // prototype is in proto.h
void
ch_log(channel_T *ch, const char *fmt, ...)
{
***************
*** 4348,4367 ****
{
channel->ch_to_be_closed = (1U << PART_COUNT);
channel_close_now(channel);
! /* channel may have been freed, start over */
channel = first_channel;
continue;
}
if (channel->ch_to_be_freed || channel->ch_killing)
{
channel_free(channel);
! /* channel has been freed, start over */
channel = first_channel;
continue;
}
if (channel->ch_refcount == 0 && !channel_still_useful(channel))
{
! /* channel is no longer useful, free it */
channel_free(channel);
channel = first_channel;
part = PART_SOCK;
--- 4348,4372 ----
{
channel->ch_to_be_closed = (1U << PART_COUNT);
channel_close_now(channel);
! // channel may have been freed, start over
channel = first_channel;
continue;
}
if (channel->ch_to_be_freed || channel->ch_killing)
{
+ if (channel->ch_killing)
+ {
+ channel_free_contents(channel);
+ channel->ch_job->jv_channel = NULL;
+ }
channel_free(channel);
! // channel has been freed, start over
channel = first_channel;
continue;
}
if (channel->ch_refcount == 0 && !channel_still_useful(channel))
{
! // channel is no longer useful, free it
channel_free(channel);
channel = first_channel;
part = PART_SOCK;
***************
*** 5487,5501 ****
channel_need_redraw = TRUE;
}
! if (job->jv_channel != NULL
! && job->jv_channel->ch_anonymous_pipe && !job->jv_channel->ch_killing)
! {
! ++safe_to_invoke_callback;
! channel_free_contents(job->jv_channel);
! job->jv_channel->ch_job = NULL;
! job->jv_channel = NULL;
! --safe_to_invoke_callback;
! }
// Do not free the job in case the close callback of the associated channel
// isn't invoked yet and may get information by job_info().
--- 5492,5499 ----
channel_need_redraw = TRUE;
}
! if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe)
! job->jv_channel->ch_killing = TRUE;
// Do not free the job in case the close callback of the associated channel
// isn't invoked yet and may get information by job_info().
*** ../vim-8.1.0959/src/version.c 2019-02-20 22:18:59.990044254 +0100
--- src/version.c 2019-02-20 22:43:03.024385639 +0100
***************
*** 781,782 ****
--- 781,784 ----
{ /* Add new patch number below this line */
+ /**/
+ 960,
/**/
--
The average life of an organization chart is six months. You can safely
ignore any order from your boss that would take six months to complete.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Bram@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 ///
|