[PATCH] D54889: Fiber support for thread sanitizer
Yuri Per via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 3 04:23:26 PST 2018
yuri added a comment.
In D54889#1309646 <https://reviews.llvm.org/D54889#1309646>, @dvyukov wrote:
> I think single threaded programs would also benefit from swapcontext support. At the very least it will give correct stacks. I think tsan shadow stack can also overflow on some fibers patterns (if a fiber has uneven number of function entries and exits).
Got it.
> I also wonder if it's theoretically possible to support fibers done with longjmp. I did fibers in Relacy with makecontext+swapcontext to do an initial switch to a new fiber, and then setjmp/longjmp to switch between already running fibers. If that's the common pattern, then we could see in longjmp that we are actually switching to a different stack and do fiber switch.
> No need to do this initially, I am just wondering if we can support more real programs without annotations (qemu developers also hit unsupported fibers in tsan).
Maybe disabling interceptors before setmp/longjmp and enabling after it will help?
> Re cleanup, we could do it the same way we cleanup atomic variables. Each atomic variable hold a large context object in tsan, but there are no explicit destructors for atomic variables (and it probably would not be feasible to ask users to annotate each atomic var). So we should have most of the required machinery already.
Are sure it is good solution?
- Fiber context is much larger then context of atomic
- It is not possible to correctly recreate fiber context with shadow stack if it was lost
QEMU already have annotations for Address Sanitizer at points of fiber switch. It is not a big problem to add annotations for Thread Sanitizer at the same places.
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