hwasan: Move stack ring buffer initialization before InitStackAndTls.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 17 Aug 2021 03:13:42 +0000 (20:13 -0700)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 17 Aug 2021 17:18:07 +0000 (10:18 -0700)
commitaffb132ab89f0acffcbaf20b9357bf9e966985fe
treece112440b92cc70b3995cf8d41f0ab92877ebab5
parentdfea011a37797f77ef526880694254cb6e655a8e
hwasan: Move stack ring buffer initialization before InitStackAndTls.

D104248 moved the call to GetThreadStackAndTls to before the
initialization of the ring buffer TLS slot. As a result, if libc
is instrumented we crash in pthread_getattr_np which is called from
__sanitizer::GetThreadStackTopAndBottom.

Fix the problem by moving the stack ring buffer initialization before
the call to InitStackAndTls.

Differential Revision: https://reviews.llvm.org/D108184
compiler-rt/lib/hwasan/hwasan_thread.cpp