This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Address Sanitizer vs. swapcontext
- From: Ian Lance Taylor <iant at google dot com>
- To: Avi Kivity <avi at scylladb dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>, Asias He <asias at scylladb dot com>, Tomasz Grabiec <tgrabiec at scylladb dot com>
- Date: Thu, 19 Nov 2015 17:29:25 -0800
- Subject: Re: Address Sanitizer vs. swapcontext
- Authentication-results: sourceware.org; auth=none
- References: <564DA343 dot 60703 at scylladb dot com>
On Thu, Nov 19, 2015 at 2:24 AM, Avi Kivity <avi@scylladb.com> wrote:
>
> I am using the swapcontext family to implement user-level threading.
> Specifically, only getcontext(), setcontext(), and makecontext() are used,
> during thread creation and teardown. Beyond the initial switch into a
> thread, I use setjmp()/longjmp() as they are significantly faster.
>
> This works well, except that in combination with Address Sanitizer I
> stack-buffer-overflow errors accessing variables on a user-level-thread
> stack, which, as far as I can tell, are false positives.
>
> See for example https://github.com/scylladb/scylla/issues/533.
>
> Is there any workaround for this? I am willing to write an alternate code
> path for debugging. What would work here? sigaltstack()?
If you #include <asan_interface.h>, you can use macros like
ASAN_UNPOISON_MEMORY to tell asan that certain memory is OK to access.
Ian