Skip to content

Commit

Permalink
Try dumping core on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Sep 24, 2024
1 parent 6dcb8ba commit df1c7d1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
48 changes: 48 additions & 0 deletions cpp/src/arrow/filesystem/s3_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#ifndef _WIN32
# include <signal.h>
# include <sys/wait.h>
#endif

Expand Down Expand Up @@ -136,5 +137,52 @@ Result<std::shared_ptr<MinioTestServer>> MinioTestEnvironment::GetOneServer() {
return impl_->server_generator_().result();
}

namespace {

#ifndef _WIN32
// HACK: try and debug GH-40410 by using an homegrown timeout that should trigger
// a coredump and automatic backtrace.
using ::arrow::internal::ReinstateSignalHandler;
using ::arrow::internal::SetSignalHandler;
using ::arrow::internal::SignalHandler;

constexpr int kSigAlrmTimeout = 4 * 60; // seconds
::arrow::internal::SignalHandler old_sigalrm_handler;

void SigAlrmHandler(int signum) {
alarm(0);
raise(SIGABRT);
}

void SetTimeoutSignal() {
old_sigalrm_handler = SetSignalHandler(SIGALRM, SignalHandler(&SigAlrmHandler)).ValueOrDie();
alarm(kSigAlrmTimeout);
}

void ClearTimeoutSignal() {
alarm(0);
ReinstateSignalHandler(SIGALRM, old_sigalrm_handler.callback());
}
#endif

}

void S3Environment::SetUp() {
// Change this to increase logging during tests
S3GlobalOptions options;
options.log_level = S3LogLevel::Fatal;
ASSERT_OK(InitializeS3(options));
#ifndef _WIN32
SetTimeoutSignal();
#endif
}

void S3Environment::TearDown() {
#ifndef _WIN32
ClearTimeoutSignal();
#endif
ASSERT_OK(FinalizeS3());
}

} // namespace fs
} // namespace arrow
10 changes: 2 additions & 8 deletions cpp/src/arrow/filesystem/s3_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,8 @@ class S3Environment : public ::testing::Environment {
// condition accessing environment variables.
S3Environment() : ec2_metadata_disabled_guard_("AWS_EC2_METADATA_DISABLED", "true") {}

void SetUp() override {
// Change this to increase logging during tests
S3GlobalOptions options;
options.log_level = S3LogLevel::Fatal;
ASSERT_OK(InitializeS3(options));
}

void TearDown() override { ASSERT_OK(FinalizeS3()); }
void SetUp() override;
void TearDown() override;

private:
EnvVarGuard ec2_metadata_disabled_guard_;
Expand Down

0 comments on commit df1c7d1

Please sign in to comment.