[PATCH] D20913: [asan] add primitives that allow coroutine implementations

Philippe Daouadi via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 12:32:33 PDT 2016


blastrock added a comment.

In http://reviews.llvm.org/D20913#453386, @filcab wrote:

> The way I see it, you could do something like (I'm giving vars/functions/members totally different names to avoid ambiguity with the current names. Feel free to keep something closer to your current ones):
>  `__sanitizer_fiber_switch_start(void *ctx, uptr size);`
>  This function is passed the fiber's or the thread's stack bounds, and sets `next_stack_{top,bottom}`.
>
> `__sanitizer_fiber_switch_finish();`
>  This function is run in the new stack that you switched to and removes the current `stack_{top,bottom}`, replacing with what was in `next_stack_{top,bottom}` (setting the latter ones to `0`, after).
>
> That way, you only have one primitive to deal with (This follows from our simple fiber implementation. Yours might have functionality that requires the current implementation. Please let me know).


My implementation does not know about the thread's stack bounds. It could ask them through pthread and store them in some thread_local storage to avoid asking them each time.

Also, this interface is based on what I saw in facebook's folly, here https://github.com/facebook/folly/commit/2ea64dd24946cbc9f3f4ac3f6c6b98a486c56e73 , so they decided to do it this way too.

This interface currently makes it easier to annotate code, but if you think simplifying asan's internals is worth it, I don't mind changing it.


http://reviews.llvm.org/D20913





More information about the llvm-commits mailing list