mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-16 02:42:23 +08:00
Merge pull request #4453 from sfc-gh-anoyes/anoyes/boost-valgrind
Inform boost context of valgrind usage
This commit is contained in:
commit
a80c290cad
@ -62,8 +62,13 @@ if(USE_SANITIZER)
|
|||||||
message(FATAL_ERROR "Sanitizers are not supported on Windows")
|
message(FATAL_ERROR "Sanitizers are not supported on Windows")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "A sanitizer is enabled, need to build boost from source")
|
message(STATUS "A sanitizer is enabled, need to build boost from source")
|
||||||
compile_boost(TARGET boost_asan BUILD_ARGS context-impl=ucontext
|
if (USE_VALGRIND)
|
||||||
CXXFLAGS ${SANITIZER_COMPILE_OPTIONS} LDFLAGS ${SANITIZER_LINK_OPTIONS})
|
compile_boost(TARGET boost_asan BUILD_ARGS valgrind=on
|
||||||
|
CXXFLAGS ${SANITIZER_COMPILE_OPTIONS} LDFLAGS ${SANITIZER_LINK_OPTIONS})
|
||||||
|
else()
|
||||||
|
compile_boost(TARGET boost_asan BUILD_ARGS context-impl=ucontext
|
||||||
|
CXXFLAGS ${SANITIZER_COMPILE_OPTIONS} LDFLAGS ${SANITIZER_LINK_OPTIONS})
|
||||||
|
endif()
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -168,7 +168,10 @@ else()
|
|||||||
if(NOT CLANG)
|
if(NOT CLANG)
|
||||||
message(FATAL_ERROR "Unsupported configuration: USE_MSAN only works with Clang")
|
message(FATAL_ERROR "Unsupported configuration: USE_MSAN only works with Clang")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND SANITIZER_COMPILE_OPTIONS -fsanitize=memory -fsanitize-memory-track-origins=2)
|
list(APPEND SANITIZER_COMPILE_OPTIONS
|
||||||
|
-fsanitize=memory
|
||||||
|
-fsanitize-memory-track-origins=2
|
||||||
|
-DBOOST_USE_UCONTEXT)
|
||||||
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=memory)
|
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=memory)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -180,23 +183,25 @@ else()
|
|||||||
list(APPEND SANITIZER_COMPILE_OPTIONS
|
list(APPEND SANITIZER_COMPILE_OPTIONS
|
||||||
-fsanitize=undefined
|
-fsanitize=undefined
|
||||||
# TODO(atn34) Re-enable -fsanitize=alignment once https://github.com/apple/foundationdb/issues/1434 is resolved
|
# TODO(atn34) Re-enable -fsanitize=alignment once https://github.com/apple/foundationdb/issues/1434 is resolved
|
||||||
-fno-sanitize=alignment)
|
-fno-sanitize=alignment
|
||||||
|
-DBOOST_USE_UCONTEXT)
|
||||||
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=undefined)
|
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=undefined)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_TSAN)
|
if(USE_TSAN)
|
||||||
list(APPEND SANITIZER_COMPILE_OPTIONS -fsanitize=thread)
|
list(APPEND SANITIZER_COMPILE_OPTIONS -fsanitize=thread -DBOOST_USE_UCONTEXT)
|
||||||
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=thread)
|
list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=thread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(USE_SANITIZER OFF)
|
if(USE_VALGRIND)
|
||||||
|
list(APPEND SANITIZER_COMPILE_OPTIONS -DBOOST_USE_VALGRIND)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SANITIZER_COMPILE_OPTIONS)
|
if(SANITIZER_COMPILE_OPTIONS)
|
||||||
add_compile_options(${SANITIZER_COMPILE_OPTIONS})
|
add_compile_options(${SANITIZER_COMPILE_OPTIONS})
|
||||||
set(USE_SANITIZER ON)
|
|
||||||
endif()
|
endif()
|
||||||
if(SANITIZER_LINK_OPTIONS)
|
if(SANITIZER_LINK_OPTIONS)
|
||||||
add_link_options(${SANITIZER_LINK_OPTIONS})
|
add_link_options(${SANITIZER_LINK_OPTIONS})
|
||||||
set(USE_SANITIZER ON)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PORTABLE_BINARY)
|
if(PORTABLE_BINARY)
|
||||||
|
@ -97,6 +97,10 @@ if(GO_EXECUTABLE AND NOT WIN32)
|
|||||||
else()
|
else()
|
||||||
set(WITH_GO OFF)
|
set(WITH_GO OFF)
|
||||||
endif()
|
endif()
|
||||||
|
if (USE_SANITIZER)
|
||||||
|
# Disable building go for sanitizers, since _stacktester doesn't link properly
|
||||||
|
set(WITH_GO OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Ruby
|
# Ruby
|
||||||
|
@ -63,12 +63,18 @@ struct Coroutine /*: IThreadlike*/ {
|
|||||||
|
|
||||||
void unblock() {
|
void unblock() {
|
||||||
//Coro_switchTo_( swapCoro(coro), coro );
|
//Coro_switchTo_( swapCoro(coro), coro );
|
||||||
blocked.send(Void());
|
|
||||||
|
// Copy blocked before calling send, since the call to send might destroy it.
|
||||||
|
auto b = blocked;
|
||||||
|
b.send(Void());
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(Future<Void> const& what) {
|
void waitFor(Future<Void> const& what) {
|
||||||
(*sink)(what);
|
ASSERT(current_coro == this);
|
||||||
|
current_coro = nullptr;
|
||||||
|
(*sink)(what); // Pass control back to the switcher actor
|
||||||
ASSERT(what.isReady());
|
ASSERT(what.isReady());
|
||||||
|
current_coro = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -80,10 +86,7 @@ protected:
|
|||||||
} catch (Error& e) {
|
} catch (Error& e) {
|
||||||
// We just want to transfer control back to the coroutine. The coroutine will handle the error.
|
// We just want to transfer control back to the coroutine. The coroutine will handle the error.
|
||||||
}
|
}
|
||||||
current_coro = self;
|
(*self->coro)(); // Transfer control to the coroutine. This call "returns" after waitFor is called.
|
||||||
(*self->coro)(); // Transfer control to the coroutine, and wait until the coroutine has a future it needs to
|
|
||||||
// wait for
|
|
||||||
current_coro = nullptr;
|
|
||||||
wait(delay(0, g_network->getCurrentTask()));
|
wait(delay(0, g_network->getCurrentTask()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,10 +108,10 @@ protected:
|
|||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<coro_t::pull_type> coro;
|
|
||||||
coro_t::push_type* sink;
|
coro_t::push_type* sink;
|
||||||
Promise<Void> blocked;
|
Promise<Void> blocked;
|
||||||
std::shared_ptr<bool> alive{ std::make_shared<bool>(true) };
|
std::shared_ptr<bool> alive{ std::make_shared<bool>(true) };
|
||||||
|
std::unique_ptr<coro_t::pull_type> coro;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Threadlike, class Mutex, bool IS_CORO>
|
template <class Threadlike, class Mutex, bool IS_CORO>
|
||||||
@ -285,9 +288,8 @@ void CoroThreadPool::waitFor( Future<Void> what ) {
|
|||||||
ASSERT(current_coro != nullptr);
|
ASSERT(current_coro != nullptr);
|
||||||
if (what.isReady()) return;
|
if (what.isReady()) return;
|
||||||
// double t = now();
|
// double t = now();
|
||||||
auto c = current_coro;
|
current_coro->waitFor(what);
|
||||||
current_coro = nullptr;
|
what.get(); // Throw if |what| is an error
|
||||||
c->send(what);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right After INet2::run
|
// Right After INet2::run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user