Commit 11c023e
committed
Prevent crash on unclean disconnect if abandoned IPC call returns interface pointer
This is a fix for bitcoin/bitcoin#34250 which reports
that bitcoin node crashes if a rust stratrumv2 mining client calls
BlockTemplate.waitNext() and disconnects without waiting for a response from
the call, and if mempool fees increased so the call returns a non-null
interface BlockTemplate pointer.
The node would crash in this case while trying to call MakeProxyServer on the
returned BlockTemplate pointer, which would fail because MakeProxyServer would
try to use a reference to the Connection object that had been deleted as a as a
result of the disconnect.
The fix works by:
- Adding a Connection::m_canceler member variable and using it to cancel any
IPC response promises that are pending when the connection is destroyed.
- Updating type-context.h PassField() function to use promise.attach() as
described https://capnproto.org/cxxrpc.html#cancellation to detect
cancellation and set a ServerContext::m_canceled variable.
- Updating ServerCall to check the ServerContext::m_canceled status after any
C++ server method returns, and throw an exception if it is set.
- Updating type-context.h PassField() function to deal with the exception
by catching and logging it, and to deal with canceled status by not
trying to fulfill the canceled promise.1 parent 8d3efbc commit 11c023e
File tree
7 files changed
+199
-22
lines changed- include/mp
- src/mp
7 files changed
+199
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
51 | 62 | | |
52 | 63 | | |
53 | 64 | | |
| |||
421 | 432 | | |
422 | 433 | | |
423 | 434 | | |
424 | | - | |
| 435 | + | |
425 | 436 | | |
426 | 437 | | |
427 | 438 | | |
428 | | - | |
| 439 | + | |
429 | 440 | | |
430 | 441 | | |
431 | 442 | | |
432 | 443 | | |
433 | 444 | | |
434 | 445 | | |
435 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
436 | 450 | | |
437 | 451 | | |
438 | 452 | | |
| |||
445 | 459 | | |
446 | 460 | | |
447 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
448 | 467 | | |
449 | 468 | | |
450 | 469 | | |
| |||
696 | 715 | | |
697 | 716 | | |
698 | 717 | | |
699 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
700 | 727 | | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
711 | 737 | | |
712 | 738 | | |
713 | 739 | | |
714 | 740 | | |
715 | 741 | | |
716 | | - | |
717 | | - | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
718 | 745 | | |
719 | 746 | | |
720 | 747 | | |
| |||
724 | 751 | | |
725 | 752 | | |
726 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
727 | 759 | | |
728 | 760 | | |
729 | 761 | | |
| |||
732 | 764 | | |
733 | 765 | | |
734 | 766 | | |
735 | | - | |
| 767 | + | |
736 | 768 | | |
737 | 769 | | |
738 | 770 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
448 | 465 | | |
449 | 466 | | |
450 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| |||
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
93 | 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 | + | |
| 128 | + | |
94 | 129 | | |
95 | 130 | | |
96 | 131 | | |
97 | 132 | | |
98 | | - | |
99 | 133 | | |
100 | 134 | | |
101 | 135 | | |
102 | 136 | | |
103 | 137 | | |
104 | 138 | | |
105 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
106 | 148 | | |
107 | 149 | | |
108 | 150 | | |
109 | 151 | | |
110 | 152 | | |
111 | 153 | | |
| 154 | + | |
| 155 | + | |
112 | 156 | | |
113 | 157 | | |
114 | 158 | | |
| |||
120 | 164 | | |
121 | 165 | | |
122 | 166 | | |
| 167 | + | |
123 | 168 | | |
124 | | - | |
125 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
126 | 183 | | |
127 | 184 | | |
128 | 185 | | |
| |||
131 | 188 | | |
132 | 189 | | |
133 | 190 | | |
134 | | - | |
| 191 | + | |
135 | 192 | | |
136 | 193 | | |
137 | 194 | | |
| |||
147 | 204 | | |
148 | 205 | | |
149 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
150 | 213 | | |
151 | 214 | | |
152 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
244 | 303 | | |
245 | 304 | | |
246 | 305 | | |
0 commit comments