|
11 | 11 | #include "glusterfs/syncop.h"
|
12 | 12 | #include "glusterfs/libglusterfs-messages.h"
|
13 | 13 |
|
| 14 | +#ifdef HAVE_ASAN_API |
| 15 | +#include <sanitizer/common_interface_defs.h> |
| 16 | +#endif |
| 17 | + |
14 | 18 | #ifdef HAVE_TSAN_API
|
15 | 19 | #include <sanitizer/tsan_interface.h>
|
16 | 20 | #endif
|
@@ -275,11 +279,21 @@ synctask_yield(struct synctask *task, struct timespec *delta)
|
275 | 279 | __tsan_switch_to_fiber(task->proc->tsan.fiber, 0);
|
276 | 280 | #endif
|
277 | 281 |
|
| 282 | +#ifdef HAVE_ASAN_API |
| 283 | + __sanitizer_start_switch_fiber(&task->fake_stack, |
| 284 | + task->proc->sched.uc_stack.ss_sp, |
| 285 | + task->proc->sched.uc_stack.ss_size); |
| 286 | +#endif |
| 287 | + |
278 | 288 | if (swapcontext(&task->ctx, &task->proc->sched) < 0) {
|
279 | 289 | gf_msg("syncop", GF_LOG_ERROR, errno, LG_MSG_SWAPCONTEXT_FAILED,
|
280 | 290 | "swapcontext failed");
|
281 | 291 | }
|
282 | 292 |
|
| 293 | +#ifdef HAVE_ASAN_API |
| 294 | + __sanitizer_finish_switch_fiber(task->proc->fake_stack, NULL, NULL); |
| 295 | +#endif |
| 296 | + |
283 | 297 | THIS = oldTHIS;
|
284 | 298 | }
|
285 | 299 |
|
@@ -363,6 +377,11 @@ synctask_wrap(void)
|
363 | 377 | wrong and can lead to crashes. */
|
364 | 378 |
|
365 | 379 | task = synctask_get();
|
| 380 | + |
| 381 | +#ifdef HAVE_ASAN_API |
| 382 | + __sanitizer_finish_switch_fiber(task->fake_stack, NULL, NULL); |
| 383 | +#endif |
| 384 | + |
366 | 385 | task->ret = task->syncfn(task->opaque);
|
367 | 386 | if (task->synccbk)
|
368 | 387 | task->synccbk(task->ret, task->frame, task->opaque);
|
@@ -694,11 +713,21 @@ synctask_switchto(struct synctask *task)
|
694 | 713 | __tsan_switch_to_fiber(task->tsan.fiber, 0);
|
695 | 714 | #endif
|
696 | 715 |
|
| 716 | +#ifdef HAVE_ASAN_API |
| 717 | + __sanitizer_start_switch_fiber(&task->proc->fake_stack, |
| 718 | + task->ctx.uc_stack.ss_sp, |
| 719 | + task->ctx.uc_stack.ss_size); |
| 720 | +#endif |
| 721 | + |
697 | 722 | if (swapcontext(&task->proc->sched, &task->ctx) < 0) {
|
698 | 723 | gf_msg("syncop", GF_LOG_ERROR, errno, LG_MSG_SWAPCONTEXT_FAILED,
|
699 | 724 | "swapcontext failed");
|
700 | 725 | }
|
701 | 726 |
|
| 727 | +#ifdef HAVE_ASAN_API |
| 728 | + __sanitizer_finish_switch_fiber(task->fake_stack, NULL, NULL); |
| 729 | +#endif |
| 730 | + |
702 | 731 | if (task->state == SYNCTASK_DONE) {
|
703 | 732 | synctask_done(task);
|
704 | 733 | return;
|
|
0 commit comments