Adding changes for handling abort signals (#979)
* Adding changes for handling abort signals
* Fix the test failure
* Fixing CmakeLists error
* Addressing review comments
* fixing warnings
* fixing execute test
* Fixing abort app test
* Address review comments
* Apply suggestions from code review
* Apply suggestions from code review
* Fixes for testing issues
* Adding kernel filtering test
* Removing text input file
* fix formatting issues
* misc fix
* Suppress signal-unsafe error in ThreadSanitizer
- rename signal handler to rocprofv3_error_signal_handler to ensure specific filtering
* Fix rocprofv3 aborted-app validation
---------
Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
[ROCm/rocprofiler-sdk commit: 94b5d9be3f]
This commit is contained in:
@@ -48,13 +48,16 @@
|
||||
#include <rocprofiler-sdk/internal_threading.h>
|
||||
#include <rocprofiler-sdk/marker/api_id.h>
|
||||
#include <rocprofiler-sdk/rocprofiler.h>
|
||||
#include <algorithm>
|
||||
#include <rocprofiler-sdk/cxx/hash.hpp>
|
||||
#include <rocprofiler-sdk/cxx/operators.hpp>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
@@ -1753,6 +1756,9 @@ get_main_function()
|
||||
static main_func_t user_main = nullptr;
|
||||
return user_main;
|
||||
}
|
||||
|
||||
bool signal_handler_exit =
|
||||
rocprofiler::tool::get_env("ROCPROF_INTERNAL_TEST_SIGNAL_HANDLER_VIA_EXIT", false);
|
||||
} // namespace
|
||||
|
||||
#define ROCPROFV3_INTERNAL_API __attribute__((visibility("internal")));
|
||||
@@ -1761,6 +1767,15 @@ extern "C" {
|
||||
void
|
||||
rocprofv3_set_main(main_func_t main_func) ROCPROFV3_INTERNAL_API;
|
||||
|
||||
void
|
||||
rocprofv3_error_signal_handler(int signo)
|
||||
{
|
||||
finalize_rocprofv3();
|
||||
// below is for testing purposes. re-raising the signal causes CTest to ignore WILL_FAIL ON
|
||||
if(signal_handler_exit) ::exit(signo);
|
||||
::raise(signo);
|
||||
}
|
||||
|
||||
int
|
||||
rocprofv3_main(int argc, char** argv, char** envp) ROCPROFV3_INTERNAL_API;
|
||||
|
||||
@@ -1848,6 +1863,20 @@ rocprofv3_main(int argc, char** argv, char** envp)
|
||||
|
||||
initialize_rocprofv3();
|
||||
|
||||
struct sigaction sig_act = {};
|
||||
sigemptyset(&sig_act.sa_mask);
|
||||
sig_act.sa_flags = SA_RESETHAND | SA_NODEFER;
|
||||
sig_act.sa_handler = &rocprofv3_error_signal_handler;
|
||||
for(auto signal_v : {SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, SIGFPE})
|
||||
{
|
||||
if(sigaction(signal_v, &sig_act, nullptr) != 0)
|
||||
{
|
||||
auto _errno_v = errno;
|
||||
ROCP_ERROR << "error setting signal handler for " << signal_v
|
||||
<< " :: " << strerror(_errno_v);
|
||||
}
|
||||
}
|
||||
|
||||
auto ret = CHECK_NOTNULL(get_main_function())(argc, argv, envp);
|
||||
|
||||
finalize_rocprofv3();
|
||||
|
||||
Reference in New Issue
Block a user