|
39 | 39 | # include <limits.h>
|
40 | 40 | #endif
|
41 | 41 |
|
| 42 | +#ifdef __SANITIZE_ADDRESS__ |
| 43 | +# include <sanitizer/common_interface_defs.h> |
| 44 | +#endif |
| 45 | + |
42 | 46 | ZEND_API zend_class_entry *zend_ce_fiber;
|
43 | 47 | static zend_class_entry *zend_ce_fiber_error;
|
44 | 48 |
|
@@ -180,13 +184,21 @@ static ZEND_NORETURN void zend_fiber_trampoline(transfer_t transfer)
|
180 | 184 | {
|
181 | 185 | zend_fiber_context *context = transfer.data;
|
182 | 186 |
|
| 187 | +#ifdef __SANITIZE_ADDRESS__ |
| 188 | + __sanitizer_finish_switch_fiber(NULL, &context->stack.bottom, &context->stack.capacity); |
| 189 | +#endif |
| 190 | + |
183 | 191 | context->caller = transfer.context;
|
184 | 192 |
|
185 | 193 | context->function(context);
|
186 | 194 |
|
187 | 195 | context->self = NULL;
|
188 | 196 |
|
189 |
| - zend_fiber_suspend_context(context); |
| 197 | +#ifdef __SANITIZE_ADDRESS__ |
| 198 | + __sanitizer_start_switch_fiber(NULL, context->stack.bottom, context->stack.capacity); |
| 199 | +#endif |
| 200 | + |
| 201 | + jump_fcontext(context->caller, NULL); |
190 | 202 |
|
191 | 203 | abort();
|
192 | 204 | }
|
@@ -222,17 +234,35 @@ ZEND_API void zend_fiber_switch_context(zend_fiber_context *to)
|
222 | 234 | {
|
223 | 235 | ZEND_ASSERT(to && to->self && to->stack.pointer && "Invalid fiber context");
|
224 | 236 |
|
| 237 | +#ifdef __SANITIZE_ADDRESS__ |
| 238 | + void *fake_stack; |
| 239 | + __sanitizer_start_switch_fiber(&fake_stack, to->stack.pointer, to->stack.size); |
| 240 | +#endif |
| 241 | + |
225 | 242 | transfer_t transfer = jump_fcontext(to->self, to);
|
226 | 243 |
|
| 244 | +#ifdef __SANITIZE_ADDRESS__ |
| 245 | + __sanitizer_finish_switch_fiber(fake_stack, &to->stack.bottom, &to->stack.capacity); |
| 246 | +#endif |
| 247 | + |
227 | 248 | to->self = transfer.context;
|
228 | 249 | }
|
229 | 250 |
|
230 | 251 | ZEND_API void zend_fiber_suspend_context(zend_fiber_context *current)
|
231 | 252 | {
|
232 | 253 | ZEND_ASSERT(current && current->caller && current->stack.pointer && "Invalid fiber context");
|
233 | 254 |
|
| 255 | +#ifdef __SANITIZE_ADDRESS__ |
| 256 | + void *fake_stack; |
| 257 | + __sanitizer_start_switch_fiber(&fake_stack, current->stack.bottom, current->stack.capacity); |
| 258 | +#endif |
| 259 | + |
234 | 260 | transfer_t transfer = jump_fcontext(current->caller, NULL);
|
235 | 261 |
|
| 262 | +#ifdef __SANITIZE_ADDRESS__ |
| 263 | + __sanitizer_finish_switch_fiber(fake_stack, ¤t->stack.bottom, ¤t->stack.capacity); |
| 264 | +#endif |
| 265 | + |
236 | 266 | current->caller = transfer.context;
|
237 | 267 | }
|
238 | 268 |
|
|
0 commit comments