Commit 0174450
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
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 ProxyServer<Thread>::post to use promise.attach() as
described https://capnproto.org/cxxrpc.html#cancellation to detect
cancellation and set a ServerContext::request_canceled variable.
- Updating ServerCall to check the ServerContext::request_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.1 parent ddb5f74 commit 0174450
7 files changed
Lines changed: 251 additions & 16 deletions
| 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 | + | |
| 62 | + | |
| 63 | + | |
51 | 64 | | |
52 | 65 | | |
53 | 66 | | |
| |||
421 | 434 | | |
422 | 435 | | |
423 | 436 | | |
424 | | - | |
| 437 | + | |
425 | 438 | | |
426 | 439 | | |
427 | 440 | | |
428 | | - | |
| 441 | + | |
429 | 442 | | |
430 | 443 | | |
431 | 444 | | |
432 | 445 | | |
433 | 446 | | |
434 | 447 | | |
435 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
436 | 452 | | |
437 | 453 | | |
438 | 454 | | |
| |||
445 | 461 | | |
446 | 462 | | |
447 | 463 | | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
448 | 469 | | |
449 | 470 | | |
450 | 471 | | |
| |||
696 | 717 | | |
697 | 718 | | |
698 | 719 | | |
699 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
700 | 729 | | |
701 | | - | |
| 730 | + | |
702 | 731 | | |
703 | 732 | | |
704 | 733 | | |
| |||
712 | 741 | | |
713 | 742 | | |
714 | 743 | | |
715 | | - | |
716 | | - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
717 | 753 | | |
718 | 754 | | |
719 | 755 | | |
| |||
723 | 759 | | |
724 | 760 | | |
725 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
726 | 767 | | |
727 | 768 | | |
728 | 769 | | |
| |||
731 | 772 | | |
732 | 773 | | |
733 | 774 | | |
734 | | - | |
| 775 | + | |
735 | 776 | | |
736 | 777 | | |
737 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
449 | | - | |
450 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
451 | 478 | | |
452 | 479 | | |
453 | 480 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
| |||
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
92 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
93 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
94 | 130 | | |
95 | 131 | | |
96 | 132 | | |
| |||
102 | 138 | | |
103 | 139 | | |
104 | 140 | | |
105 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
106 | 150 | | |
107 | 151 | | |
108 | 152 | | |
109 | 153 | | |
110 | 154 | | |
111 | 155 | | |
| 156 | + | |
| 157 | + | |
112 | 158 | | |
113 | 159 | | |
114 | 160 | | |
| |||
120 | 166 | | |
121 | 167 | | |
122 | 168 | | |
| 169 | + | |
123 | 170 | | |
124 | | - | |
125 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
126 | 185 | | |
127 | 186 | | |
128 | 187 | | |
| |||
131 | 190 | | |
132 | 191 | | |
133 | 192 | | |
134 | | - | |
| 193 | + | |
135 | 194 | | |
136 | 195 | | |
137 | 196 | | |
| |||
147 | 206 | | |
148 | 207 | | |
149 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
150 | 215 | | |
151 | 216 | | |
152 | 217 | | |
| |||
0 commit comments