Moving opt-in custom signal handler from UnitTests into RCCL (#550)
* Enable via RCCL_ENABLE_SIGNALHANDLER=1
This commit is contained in:
@@ -5,14 +5,8 @@
|
||||
************************************************************************/
|
||||
|
||||
#include "TestBedChild.hpp"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_BFD
|
||||
#include "BfdBacktrace.hpp"
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
|
||||
#define CHILD_NCCL_CALL(cmd, msg) \
|
||||
@@ -29,47 +23,6 @@
|
||||
#define PIPE_READ(val) \
|
||||
if (read(childReadFd, &val, sizeof(val)) != sizeof(val)) return TEST_FAIL;
|
||||
|
||||
|
||||
void sig_handler(int signum){
|
||||
printf("\n [%d] Inside handler function signal is %d\n", getpid(), signum);
|
||||
|
||||
#ifdef HAVE_BFD
|
||||
void *addresses[BACKTRACE_MAX];
|
||||
int num_addresses = backtrace(addresses, BACKTRACE_MAX);
|
||||
struct backtrace_file file;
|
||||
backtrace_line line;
|
||||
backtrace_h bckt;
|
||||
bckt.size = 0;
|
||||
|
||||
for (int i = 0; i < num_addresses; ++i) {
|
||||
file.dl.address = (unsigned long)addresses[i];
|
||||
if (dl_lookup_address(&file.dl) && load_file(&file)) {
|
||||
bckt.size += get_line_info(&file, 1,
|
||||
bckt.lines + bckt.size,
|
||||
BACKTRACE_MAX - bckt.size);
|
||||
unload_file(&file);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<BACKTRACE_MAX; i++ ){
|
||||
if ((char*)bckt.lines[i].address == NULL) break;
|
||||
printf("%p %s : %s line %u\n", (char*)bckt.lines[i].address, bckt.lines[i].file, bckt.lines[i].function, bckt.lines[i].lineno);
|
||||
}
|
||||
#else
|
||||
#define BT_BUF_SIZE 1024
|
||||
void *buffer[BT_BUF_SIZE];
|
||||
char **strings;
|
||||
|
||||
int nptrs = backtrace(buffer, BT_BUF_SIZE);
|
||||
strings = backtrace_symbols(buffer, nptrs);
|
||||
for (int j = 0; j < nptrs; j++)
|
||||
printf("%s\n", strings[j]);
|
||||
free (strings);
|
||||
#endif
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
namespace RcclUnitTesting
|
||||
{
|
||||
TestBedChild::TestBedChild(int const childId, bool const verbose, int const printValues)
|
||||
@@ -77,11 +30,6 @@ namespace RcclUnitTesting
|
||||
this->childId = childId;
|
||||
this->verbose = verbose;
|
||||
this->printValues = printValues;
|
||||
|
||||
signal(SIGILL, sig_handler);
|
||||
signal(SIGBUS, sig_handler);
|
||||
signal(SIGFPE, sig_handler);
|
||||
signal(SIGSEGV, sig_handler);
|
||||
}
|
||||
|
||||
int TestBedChild::InitPipes()
|
||||
|
||||
Reference in New Issue
Block a user