Commit c9e0d40
committed
Fix
The issue is that std::promise internally also used thread local
storage, in a call to `std::call_once` in `std::promise::set_value()`.
The theory is that since all paths in `Send()` run this `std::call_once`
routine and from then on, then Coroutine function looks like a normal
function, the compiler inlined `set_value()` and moved the common parts
of it to a common location for all paths before the suspension point in
WriteMessage(yc).
When finally the coroutine is resumes, it is likely that that happens
under a different thread, which still has `__once_callable` in
`std::call_once` set as `nullptr`, leading to the segmentation fault.
The fix is to not use std::promise across coroutine suspension points
and instead reimplement the functionality we required from it in a small
helper class `SyncResult` that does not require any thread local storag.PerfdataWriterConnection segfaults on non-X86 architectures1 parent ad8563b commit c9e0d40
2 files changed
Lines changed: 67 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
21 | 22 | | |
22 | 23 | | |
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 | + | |
24 | 81 | | |
25 | 82 | | |
26 | 83 | | |
| |||
66 | 123 | | |
67 | 124 | | |
68 | 125 | | |
69 | | - | |
| 126 | + | |
70 | 127 | | |
71 | 128 | | |
72 | 129 | | |
| |||
75 | 132 | | |
76 | 133 | | |
77 | 134 | | |
78 | | - | |
| 135 | + | |
79 | 136 | | |
80 | | - | |
| 137 | + | |
81 | 138 | | |
82 | 139 | | |
83 | 140 | | |
84 | 141 | | |
85 | 142 | | |
86 | 143 | | |
87 | | - | |
| 144 | + | |
88 | 145 | | |
89 | 146 | | |
90 | 147 | | |
| |||
98 | 155 | | |
99 | 156 | | |
100 | 157 | | |
101 | | - | |
| 158 | + | |
102 | 159 | | |
103 | 160 | | |
104 | 161 | | |
105 | 162 | | |
106 | 163 | | |
107 | 164 | | |
108 | | - | |
| 165 | + | |
109 | 166 | | |
110 | 167 | | |
111 | 168 | | |
| |||
0 commit comments