Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/bthread/bthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,6 @@ int bthread_equal(bthread_t t1, bthread_t t2) {
return t1 == t2;
}

#ifdef BUTIL_USE_ASAN
// Fixme!!!
// The noreturn `bthread_exit' may cause a warning of ASan, but does not abort the program.
//
// ==94463==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x00016dd7f000; bottom 0x00010b1a4000; size: 0x000062bdb000 (1656598528)
// False positive error reports may follow
#endif // BUTIL_USE_ASAN
void bthread_exit(void* retval) {
bthread::TaskGroup* g = bthread::tls_task_group;
if (g != NULL && !g->is_current_main_task()) {
Expand Down
12 changes: 11 additions & 1 deletion src/bthread/task_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ TaskGroup::~TaskGroup() {
}

#ifdef BUTIL_USE_ASAN
// Returns the **highest** address of the calling pthread's stack and its
// total size, matching brpc's `StackStorage::bottom` convention (see comment
// in bthread/stack.h: "Assume stack grows upwards"). Note that on Linux
// `pthread_attr_getstack(3)` returns the lowest address of the region, so
// we have to translate it; on macOS `pthread_get_stackaddr_np(3)` already
// returns the stack base (highest address), so we use it as-is.
int PthreadAttrGetStack(void*& stack_addr, size_t& stack_size) {
#if defined(OS_MACOSX)
stack_addr = pthread_get_stackaddr_np(pthread_self());
Expand All @@ -259,9 +265,13 @@ int PthreadAttrGetStack(void*& stack_addr, size_t& stack_size) {
LOG(ERROR) << "Fail to get pthread attributes: " << berror(rc);
return rc;
}
rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size);
void* stack_lowest = NULL;
rc = pthread_attr_getstack(&attr, &stack_lowest, &stack_size);
if (0 != rc) {
LOG(ERROR) << "Fail to get pthread stack: " << berror(rc);
} else {
// Translate lowest -> highest to match StackStorage::bottom.
stack_addr = (char*)stack_lowest + stack_size;
}
pthread_attr_destroy(&attr);
return rc;
Expand Down
Loading