forked from OSchip/llvm-project
[asan] Make GetCurrentThread RTEMS-friendly
On RTEMS, system and user code all live in a single binary and address space. There is no clean separation, and instrumented code may execute before the ASan run-time is initialized (or after it has been destroyed). Currently, GetCurrentThread() may crash if it's called before ASan run-time is initialized. Make it return nullptr instead. Similarly, fix __asan_handle_no_return so that it gives up rather than try something that may crash. Differential Revision: https://reviews.llvm.org/D46459 llvm-svn: 332888
This commit is contained in:
parent
b8346e3f07
commit
ead3b3487b
|
@ -536,6 +536,9 @@ void NOINLINE __asan_handle_no_return() {
|
|||
if (curr_thread) {
|
||||
top = curr_thread->stack_top();
|
||||
bottom = ((uptr)&local_stack - PageSize) & ~(PageSize - 1);
|
||||
} else if (SANITIZER_RTEMS) {
|
||||
// Give up On RTEMS.
|
||||
return;
|
||||
} else {
|
||||
CHECK(!SANITIZER_FUCHSIA);
|
||||
// If we haven't seen this thread, try asking the OS for stack bounds.
|
||||
|
|
|
@ -394,6 +394,9 @@ static bool ThreadStackContainsAddress(ThreadContextBase *tctx_base,
|
|||
}
|
||||
|
||||
AsanThread *GetCurrentThread() {
|
||||
if (SANITIZER_RTEMS && !asan_inited)
|
||||
return nullptr;
|
||||
|
||||
AsanThreadContext *context =
|
||||
reinterpret_cast<AsanThreadContext *>(AsanTSDGet());
|
||||
if (!context) {
|
||||
|
|
Loading…
Reference in New Issue