Commit 415081a
committed
race fix: m_on_cancel called after request finishes
This fixes a race condition in the mp.Context PassField() overload which is
used to execute async requests, that can currently trigger segfaults as
reported in bitcoin/bitcoin#34782 when a cancellation
happens after the request executes but before it returns.
The bug can be reproduced by running the unit test added in the previous commit
and was also seen in antithesis (see details in linked issue), but should be
unlikely to happen normally because the cancellation would have to happen in a
very short window for there to be a problem.
This bug was introduced commit in 0174450
which started to cancel requests on disconnects. Before that commit a
cancellation callback was not present.
This fix was originally posted in
bitcoin/bitcoin#34782 (comment)
and there is a sequence diagram explaining the bug in
bitcoin-core#249 (comment)1 parent 13870f9 commit 415081a
1 file changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
0 commit comments