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>
This commit is contained in:
SrirakshaNag
2024-07-31 22:46:01 -05:00
committed by GitHub
parent 018f3ce056
commit 94b5d9be3f
10 changed files with 244 additions and 4 deletions
+1 -1
View File
@@ -608,7 +608,7 @@ The following table lists the various fields or the columns in the output CSV fi
Kernel Filtering
+++++++++++++++++
rocprofv3 supports kernel filtering. A kernel filter is a set of a regex string (to include the kernels matching this filter), a regex string (to exclude the kernels matching this filter),
rocprofv3 supports kernel filtering for profiling. A kernel filter is a set of a regex string (to include the kernels matching this filter), a regex string (to exclude the kernels matching this filter),
and an iteration range (set of iterations of the included kernels). If the iteration range is not provided then all iterations of the included kernels are profiled.
.. code-block:: shell
+30 -1
View File
@@ -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();
@@ -27,3 +27,6 @@ mutex:external/ptl/source/PTL/TaskGroup.hh
# lock order inversion that cannot happen
mutex:source/lib/common/synchronized.hpp
# signal-unsafe function called from signal handler
signal:rocprofv3_error_signal_handler