This is an archive of the discontinued LLVM Phabricator instance.

[asan] Add AsanThread::Restart() to support thread restart
AbandonedPublic

Authored by waltl on May 4 2018, 1:50 PM.

Details

Summary

Thread restart is a feature on RTEMS where a thread may resume at an
arbitrary function entry point, but the stack and TLS state are reset.
Use AsanThread::Restart() to do the corresponding bookeeping.

Diff Detail

Event Timeline

waltl created this revision.May 4 2018, 1:50 PM
kcc added inline comments.May 4 2018, 3:03 PM
compiler-rt/lib/asan/asan_thread.cc
118 ↗(On Diff #145283)

add a comment explaining why we need Restart

waltl updated this revision to Diff 145475.May 7 2018, 8:53 AM

Address CR comments.

waltl marked an inline comment as done.May 7 2018, 8:53 AM

Who is going to call Restart() ?

waltl added a comment.May 10 2018, 2:41 PM

It's called by __sanitizer_thread_start_hook() defined in asan_rtems.cc (See https://reviews.llvm.org/D46468), which in turn will be call by RTEMS, in the code that starts/restarts a thread.

alekseyshl added inline comments.May 16 2018, 3:34 PM
compiler-rt/lib/asan/asan_thread.cc
120 ↗(On Diff #145475)

withbut -> without

124 ↗(On Diff #145475)

Since this feature is very much RTEMS specific, maybe it's better to be kept in asan_rtems.cc? Stack bounds are exposed via thread->GetStackBounds().

waltl updated this revision to Diff 147229.May 16 2018, 8:11 PM

Address CR comments

waltl marked 2 inline comments as done.May 16 2018, 8:14 PM
waltl added inline comments.
compiler-rt/lib/asan/asan_thread.cc
124 ↗(On Diff #145475)

The problem is thread->GetStackBounds() is private. I moved the definition of AsanThread::Restart() to asan_rtems.cc, but I still need the declaration in asan_thread.h. Let me know what you think.

Ah, right, it is private. Use stack_top() and stack_bottom() then, they are public.

waltl marked an inline comment as done.May 17 2018, 12:28 PM

Ah, right, it is private. Use stack_top() and stack_bottom() then, they are public.

Right. Sorry I missed that. Done, and that makes this patch obsolete.

waltl abandoned this revision.May 17 2018, 12:29 PM