Skip to content

Commit

Permalink
fix: Disable ThreadDebugInfoDeathTest for sanitizers (#11907)
Browse files Browse the repository at this point in the history
Summary:

ThreadDebugInfoDeathTest spawns off a new process and checks for its
death. These kind of tests do not bode well with sanitizers, therefore we
disable it whenever sanitizers are used.

Reviewed By: xiaoxmeng

Differential Revision: D67407663
  • Loading branch information
Bikramjeet Vig authored and facebook-github-bot committed Dec 18, 2024
1 parent fdb309f commit 29266e0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions velox/exec/tests/ThreadDebugInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ using namespace facebook::velox::exec::test;
// For clang
#ifdef __has_feature
#define IS_BUILDING_WITH_ASAN() __has_feature(address_sanitizer)
#define IS_BUILDING_WITH_TSAN() __has_feature(thread_sanitizer)
#else
// For GCC
#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__
#define IS_BUILDING_WITH_ASAN() 1
#else
#define IS_BUILDING_WITH_ASAN() 0
#endif
#if defined(__SANITIZE_THREAD__) && __SANITIZE_THREAD__
#define IS_BUILDING_WITH_TSAN() 1
#else
#define IS_BUILDING_WITH_TSAN() 0
#endif
#endif

#if IS_BUILDING_WITH_TSAN() || IS_BUILDING_WITH_ASAN()
#define IS_BUILDING_WITH_SAN
#endif

// Ensure the test class name has "DeathTest" as a prefix to ensure this runs in
Expand All @@ -63,7 +73,7 @@ DEBUG_ONLY_TEST_F(ThreadDebugInfoDeathTest, withinSeperateDriverThread) {
auto vector = makeRowVector({makeFlatVector<int64_t>({1, 2, 3, 4, 5, 6})});
registerFunction<InduceSegFaultFunction, int64_t, int64_t>({"segFault"});
auto op = PlanBuilder().values({vector}).project({"segFault(c0)"}).planNode();
#if IS_BUILDING_WITH_ASAN() == 0
#ifndef IS_BUILDING_WITH_SAN
ASSERT_DEATH(
(assertQuery(op, vector)),
".*Fatal signal handler. Query Id= TaskCursorQuery_0 Task Id= test_cursor 1.*");
Expand All @@ -77,7 +87,7 @@ DEBUG_ONLY_TEST_F(ThreadDebugInfoDeathTest, withinQueryCompilation) {
// compilation.
auto op = PlanBuilder().values({vector}).project({"segFault(1)"}).planNode();

#if IS_BUILDING_WITH_ASAN() == 0
#ifndef IS_BUILDING_WITH_SAN
ASSERT_DEATH(
(assertQuery(op, vector)),
".*Fatal signal handler. Query Id= TaskCursorQuery_0 Task Id= test_cursor 1.*");
Expand Down Expand Up @@ -105,7 +115,7 @@ DEBUG_ONLY_TEST_F(ThreadDebugInfoDeathTest, withinTheCallingThread) {
queryCtx,
exec::Task::ExecutionMode::kSerial);

#if IS_BUILDING_WITH_ASAN() == 0
#ifndef IS_BUILDING_WITH_SAN
ASSERT_DEATH(
(task->next()),
".*Fatal signal handler. Query Id= TaskCursorQuery_0 Task Id= single.execution.task.0.*");
Expand All @@ -114,7 +124,7 @@ DEBUG_ONLY_TEST_F(ThreadDebugInfoDeathTest, withinTheCallingThread) {

DEBUG_ONLY_TEST_F(ThreadDebugInfoDeathTest, noThreadContextSet) {
int* nullpointer = nullptr;
#if IS_BUILDING_WITH_ASAN() == 0
#ifndef IS_BUILDING_WITH_SAN
ASSERT_DEATH((*nullpointer = 6), ".*ThreadDebugInfo object not found.*");
#endif
folly::compiler_must_not_elide(nullpointer);
Expand Down

0 comments on commit 29266e0

Please sign in to comment.