[PATCH] D54889: Fiber support for thread sanitizer

Yuri Per via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 06:32:36 PST 2018


yuri added a comment.

In D54889#1309542 <https://reviews.llvm.org/D54889#1309542>, @dvyukov wrote:

> In D54889#1309507 <https://reviews.llvm.org/D54889#1309507>, @yuri wrote:
>
> > In D54889#1309474 <https://reviews.llvm.org/D54889#1309474>, @dvyukov wrote:
> >
> > > It's unclear how this is supposed to be used. I would expect to see an interceptor for swapcontext that will make use of this, but there is none...
> >
> >
> > Interceptor for swapcontext without additional sanitizer API is not enough because it is not known when context is created and destroyed. Actually, I am not sure if swapcontext is actually used by someone because it is slow and has strange limitations.
> >
> > My interface assumes is that users should call __tsan_switch_to_fiber() immediately before switching context and then call swapcontext or whatever he want to perform actual switch.
>
>
> What do people use nowadays?


We use custom assembler code. You can see it at https://github.com/acronis/pcs-io/blob/master/libpcs_io/pcs_ucontext.c
Previously we used sigsetjmp()/siglongjmp().
QEMU use sigsetjmp()/siglongjmp().
Boost use swapcontext().

> Will swapcontext work along with makecontext interceptor?
>  swapcontext is still used, and it's also a good way to show how the API should be used and to write tests.

It is possible to implement interceptors for swapcontext() and makecontext(), but user still have to call something when context is destroyed.

Actually, such interceptors are not needed for everyone. If application execute fibers in single thread, then it does not need any special support.
Fiber API is only useful for cases when fiber can be dispatched in any thread of the thread pool (like in Go).


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54889/new/

https://reviews.llvm.org/D54889





More information about the llvm-commits mailing list