From 476f8ddf92070981265b5685adfc620566334192 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Thu, 17 Oct 2024 01:01:55 +0000 Subject: [PATCH 01/13] This catches other exceptions that readDataset can sometimes throw when it fails to open a dataset Signed-off-by: Akshita Mavurapu --- api/bag_dataset.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/bag_dataset.cpp b/api/bag_dataset.cpp index ab04c9276b..eacdb4fcad 100644 --- a/api/bag_dataset.cpp +++ b/api/bag_dataset.cpp @@ -275,6 +275,17 @@ std::shared_ptr Dataset::open( { std::cerr << "\nUnable to open BAG file: " << fileName << " due to error: " << fileExcept.getCDetailMsg(); return nullptr; + } catch (H5::GroupIException &groupExcept) { + std::cerr << "\nAn group exception occurred opening the dataset. Error was in " + << groupExcept.getFuncName() + << ". A detailed message follows:" + << std::endl << groupExcept.getDetailMsg() << std::endl; + } catch (H5::Exception &otherException) + { + std::cerr << "\nAn unknown exception occurred opening the dataset. Error was in " + << otherException.getFuncName() + << ". A detailed message follows:" + << std::endl << otherException.getDetailMsg() << std::endl; } return pDataset; From b20d1ce7be3ec1968351db8abb0c0915f68a1dd9 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 15 Nov 2024 17:12:08 +0000 Subject: [PATCH 02/13] Make signal handler for safely printing during aborts and segfaults Signed-off-by: Akshita Mavurapu --- api/bag.cpp | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/api/bag.cpp b/api/bag.cpp index 66ec97b61b..6f9dfb5432 100644 --- a/api/bag.cpp +++ b/api/bag.cpp @@ -19,6 +19,10 @@ #include "bag_vrrefinements.h" #include "bag_vrrefinementsdescriptor.h" #include "bag_vrtrackinglist.h" +#include +#include +#include +#include #ifdef _MSC_VER #pragma warning(push) @@ -32,6 +36,7 @@ #include #include #include +#include #ifdef _MSC_VER #pragma warning(pop) @@ -40,6 +45,127 @@ namespace { +static void (*cleanup_functions[128])(int); +static int cleanup_functions_count = 0; + +// Returns 0 on success, 1 if too many functions have been set +// This is not thread safe, only call it from a single thread +int add_cleanup_function(void (*f)(int)) { + if (cleanup_functions_count >= 128) { + return 1; + } + + cleanup_functions[cleanup_functions_count] = f; + cleanup_functions_count++; + + return 0; +} + +static void bag_handler(int signal); + +struct BagAbortHook { + //void (*old_handler[255])(int); + //void (*current_handler[255])(int); + struct sigaction old_handlers[255]; + struct sigaction current_handlers[255]; + + // returns after done printing the exit message + void print_error_msg(int signal) { + // if the handlers are the same, don't call "bag handler" twice + char* signal_name; + + #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ + "the signal that caused this error was: SIG" + +#ifdef __USE_GNU + const char* signal_abbrev = sigabbrev_np(signal); +#else + const char* signal_abbrev = ""; +#endif + if (!signal_abbrev) { + signal_abbrev = ""; + } + + int stderr_fd = stderr->_fileno; + + // strlen is not async signal safe, so it can't be used here + int signal_abbrev_length = 0; + for(;;signal_abbrev_length++) { + if (signal_abbrev[signal_abbrev_length] == 0) { + break; + } + } + + //fputs(", FILE *__restrict stream); + write(stderr_fd, TERM_STRING, sizeof (TERM_STRING) - 1); + write(stderr_fd, signal_abbrev, signal_abbrev_length); + } + + void call_cleanup_functions(int signal) { + for(int i = 0; i < cleanup_functions_count; i++) { + cleanup_functions[i](signal); + } + } + + void call_previous_handler(int signal) { + if (this->old_handlers[signal].sa_handler != nullptr && this->old_handlers[signal].sa_handler != bag_handler) { + this->old_handlers[signal].sa_handler(signal); + } + } + + void handle(int signal) { + this->print_error_msg(signal); + + // if anyone set a cleanup function, call those + this->call_cleanup_functions(signal); + + // if there was a handler before this, that isn't the BAG handler, + // call that one + this->call_previous_handler(signal); + + // if nothing has exited in the previous handlers, exit here + _exit(-1); + } + + std::array handled_signals() { + return { SIGABRT, SIGILL, SIGBUS, SIGFPE }; + } + + BagAbortHook() { + // set these all to null so that when restoring them + // we know which ones were added + for (int i = 0; i < 255; i++) { + this->old_handlers[i].sa_handler = nullptr; + } + + struct sigaction old_action; + struct sigaction new_action; + for (auto sn : this->handled_signals()) { + new_action.sa_handler = bag_handler; + sigaction(sn, &new_action, &old_action); + + this->old_handlers[sn] = old_action; + } + + } + + ~BagAbortHook() { + // reset the handlers back to what they were + for (auto sn : this->handled_signals()) { + struct sigaction old_action = this->old_handlers[sn]; + sigaction(sn, &old_action, nullptr); + } + } +}; + +static BagAbortHook* current_hook; + +static void bag_handler(int signal) { + if (current_hook) { + current_hook->handle(signal); + } +} + //! Convert a BAG::CompoundDataType (C++) into a BagCompoundDataType (C). /*! \param field @@ -134,6 +260,8 @@ BagError bagFileOpen( BAG_OPEN_MODE accessMode, const char* fileName) { + auto bag_hook = BagAbortHook(); + if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -169,6 +297,7 @@ BagError bagFileOpen( BagError bagFileClose( BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; From 80ff7f55e775b6038c344b92c4959fbdd0bcc710 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Sun, 24 Nov 2024 23:23:11 +0000 Subject: [PATCH 03/13] Make the signal handler thing work and add test case Signed-off-by: Akshita Mavurapu --- api/bag.cpp | 128 +----------------------- api/signal_hook.h | 179 ++++++++++++++++++++++++++++++++++ examples/driver.cpp | 5 +- examples/test_signal_hook.cpp | 33 +++++++ 4 files changed, 216 insertions(+), 129 deletions(-) create mode 100644 api/signal_hook.h create mode 100644 examples/test_signal_hook.cpp diff --git a/api/bag.cpp b/api/bag.cpp index 6f9dfb5432..8292305e1d 100644 --- a/api/bag.cpp +++ b/api/bag.cpp @@ -20,7 +20,6 @@ #include "bag_vrrefinementsdescriptor.h" #include "bag_vrtrackinglist.h" #include -#include #include #include @@ -36,136 +35,13 @@ #include #include #include -#include +#include "signal_hook.h" #ifdef _MSC_VER #pragma warning(pop) #endif -namespace { - -static void (*cleanup_functions[128])(int); -static int cleanup_functions_count = 0; - -// Returns 0 on success, 1 if too many functions have been set -// This is not thread safe, only call it from a single thread -int add_cleanup_function(void (*f)(int)) { - if (cleanup_functions_count >= 128) { - return 1; - } - - cleanup_functions[cleanup_functions_count] = f; - cleanup_functions_count++; - - return 0; -} - -static void bag_handler(int signal); - -struct BagAbortHook { - //void (*old_handler[255])(int); - //void (*current_handler[255])(int); - struct sigaction old_handlers[255]; - struct sigaction current_handlers[255]; - - // returns after done printing the exit message - void print_error_msg(int signal) { - // if the handlers are the same, don't call "bag handler" twice - char* signal_name; - - #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ - "the signal that caused this error was: SIG" - -#ifdef __USE_GNU - const char* signal_abbrev = sigabbrev_np(signal); -#else - const char* signal_abbrev = ""; -#endif - if (!signal_abbrev) { - signal_abbrev = ""; - } - - int stderr_fd = stderr->_fileno; - - // strlen is not async signal safe, so it can't be used here - int signal_abbrev_length = 0; - for(;;signal_abbrev_length++) { - if (signal_abbrev[signal_abbrev_length] == 0) { - break; - } - } - - //fputs(", FILE *__restrict stream); - write(stderr_fd, TERM_STRING, sizeof (TERM_STRING) - 1); - write(stderr_fd, signal_abbrev, signal_abbrev_length); - } - - void call_cleanup_functions(int signal) { - for(int i = 0; i < cleanup_functions_count; i++) { - cleanup_functions[i](signal); - } - } - - void call_previous_handler(int signal) { - if (this->old_handlers[signal].sa_handler != nullptr && this->old_handlers[signal].sa_handler != bag_handler) { - this->old_handlers[signal].sa_handler(signal); - } - } - - void handle(int signal) { - this->print_error_msg(signal); - - // if anyone set a cleanup function, call those - this->call_cleanup_functions(signal); - - // if there was a handler before this, that isn't the BAG handler, - // call that one - this->call_previous_handler(signal); - - // if nothing has exited in the previous handlers, exit here - _exit(-1); - } - - std::array handled_signals() { - return { SIGABRT, SIGILL, SIGBUS, SIGFPE }; - } - - BagAbortHook() { - // set these all to null so that when restoring them - // we know which ones were added - for (int i = 0; i < 255; i++) { - this->old_handlers[i].sa_handler = nullptr; - } - - struct sigaction old_action; - struct sigaction new_action; - for (auto sn : this->handled_signals()) { - new_action.sa_handler = bag_handler; - sigaction(sn, &new_action, &old_action); - - this->old_handlers[sn] = old_action; - } - - } - - ~BagAbortHook() { - // reset the handlers back to what they were - for (auto sn : this->handled_signals()) { - struct sigaction old_action = this->old_handlers[sn]; - sigaction(sn, &old_action, nullptr); - } - } -}; - -static BagAbortHook* current_hook; - -static void bag_handler(int signal) { - if (current_hook) { - current_hook->handle(signal); - } -} - //! Convert a BAG::CompoundDataType (C++) into a BagCompoundDataType (C). /*! \param field @@ -237,8 +113,6 @@ BAG::CompoundDataType getValue( } } -} // namespace - //! Open the specified BAG. /*! \param handle diff --git a/api/signal_hook.h b/api/signal_hook.h new file mode 100644 index 0000000000..3d78f46d4f --- /dev/null +++ b/api/signal_hook.h @@ -0,0 +1,179 @@ +#ifndef BAG_SIGNAL_HOOK +#define BAG_SIGNAL_HOOK + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void (*cleanup_functions[128])(int); +static int cleanup_functions_count = 0; + +// Returns 0 on success, 1 if too many functions have been set +// This is not thread safe, only call it from a single thread +int add_cleanup_function(void (*f)(int)) { + if (cleanup_functions_count >= 128) { + return 1; + } + + cleanup_functions[cleanup_functions_count] = f; + cleanup_functions_count++; + + return 0; +} + +static void bag_handler(int signal); + +struct BagAbortHook; + +static BagAbortHook* current_hook; + +struct BagAbortHook { + BagAbortHook* previous; + //void (*old_handler[255])(int); + //void (*current_handler[255])(int); + struct sigaction old_handlers[255]; + //void (*old_handlers[255])(int); + + // returns after done printing the exit message + void print_error_msg(int signal) { + // if the handlers are the same, don't call "bag handler" twice + char* signal_name; + + #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ + "the signal that caused this error was: SIG" + +#ifdef __USE_GNU + const char* signal_abbrev = sigabbrev_np(signal); +#else + const char* signal_abbrev = ""; +#endif + if (!signal_abbrev) { + signal_abbrev = ""; + } + + int stderr_fd = stderr->_fileno; + + // strlen is not async signal safe, so it can't be used here + int signal_abbrev_length = 0; + for(;;signal_abbrev_length++) { + if (signal_abbrev[signal_abbrev_length] == 0) { + break; + } + } + + //fputs(", FILE *__restrict stream); + write(stderr_fd, TERM_STRING, sizeof (TERM_STRING) - 1); + write(stderr_fd, signal_abbrev, signal_abbrev_length); + write(stderr_fd, "\n", 1); + } + + void call_cleanup_functions(int signal) { + //std::cout << "calling cleanup functions" << std::endl; + for(int i = 0; i < cleanup_functions_count; i++) { + //std::cout << "calling cleanup function:" << i << std::endl; + cleanup_functions[i](signal); + } + } + + void call_previous_handler(int signal) { + if (this->old_handlers[signal].sa_handler != nullptr && this->old_handlers[signal].sa_handler != bag_handler) { + this->old_handlers[signal].sa_handler(signal); + } + } + + void handle(int signal) { + this->print_error_msg(signal); + + // if anyone set a cleanup function, call those + this->call_cleanup_functions(signal); + + // if there was a handler before this, that isn't the BAG handler, + // call that one + + this->call_previous_handler(signal); + + // if nothing has exited in the previous handlers, exit here + //std::cout << "exiting" << std::endl; + _exit(-1); + } + + std::array handled_signals() { + return { SIGABRT, SIGILL, SIGBUS, SIGFPE, SIGSEGV }; + } + + BagAbortHook() { + std::cout << "made hook" << std::endl; + // set these all to null so that when restoring them + // we know which ones were added + for (int i = 0; i < 255; i++) { + this->old_handlers[i].sa_handler = nullptr; + } + + struct sigaction old_action; + for (auto sn : this->handled_signals()) { + //std::cout << "setting action for signal " << sn << std::endl; + struct sigaction new_action; + new_action.sa_flags = 0; + new_action.sa_handler = bag_handler; + + // I was going to use https://en.cppreference.com/w/c/program/signal here + // but I needed to get what the old action was so that I could + // put the original handler back + // https://linux.die.net/man/2/sigaction seems to give me what it used to be + // in old action, but I'm not sure if I need to do anything special with the + // other things in the sigaction struct? + // + // Actually, I think it does support it but apparently signal is + // pretty outdated: https://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal + auto r = sigaction(sn, &new_action, &old_action); + //auto old_handler = signal(sn, bag_handler); + + /*if (old_handler == SIG_ERR) { + std::cout << "got SIG_ERR setting signal handler?" << std::endl; + } else if (old_handler == SIG_DFL) { + std::cout << "old handler was DFL" << std::endl; + } else if (old_handler == SIG_IGN) { + std::cout << "old handler was IGN" << std::endl; + }*/ + + //std::cout << "setting action returned:" << old_handler << std::endl; + + this->old_handlers[sn] = old_action; + } + this->previous = current_hook; + current_hook = this; + } + + ~BagAbortHook() { + std::cout << "resetting to original handlers" << std::endl; + // reset the handlers back to what they were + for (auto sn : this->handled_signals()) { + struct sigaction old_action = this->old_handlers[sn]; + //auto old_action = this->old_handlers[sn]; + //signal(sn, old_action); + sigaction(sn, &old_action, nullptr); + } + + current_hook = this->previous; + } +}; + +static void bag_handler(int signal) { + //std::cout << "handler" << std::endl; + if (current_hook) { + current_hook->handle(signal); + } else { + // something broke I think? + // I don't know if there's a way to deal with this + // so I'll just exit here + _exit(-2); + } +} + +#endif diff --git a/examples/driver.cpp b/examples/driver.cpp index 0160a8ed31..1260b121b8 100644 --- a/examples/driver.cpp +++ b/examples/driver.cpp @@ -1,7 +1,8 @@ + +#include #include #include #include -#include #include #include #include @@ -40,4 +41,4 @@ int main(int argc, char** argv)//argv, which is an array of pointers to strings //strcpy(filename_cstr, filename.c_str()); LLVMFuzzerTestOneInputByFile(filename.c_str()); -} \ No newline at end of file +} diff --git a/examples/test_signal_hook.cpp b/examples/test_signal_hook.cpp new file mode 100644 index 0000000000..125fc11cd4 --- /dev/null +++ b/examples/test_signal_hook.cpp @@ -0,0 +1,33 @@ +#include "../api/signal_hook.h" +#include +#include +#include +#include + +void cleanuper(int signal) { + std::cout << "cleanuper" << std::endl; +} + +void existing_handler(int signal) { + std::cout << "existing handler" << std::endl; +} + +int main(int argc, char** argv) { + signal(SIGSEGV, existing_handler); + + BagAbortHook hook; + + add_cleanup_function(cleanuper); + + std::cout << "signal going to happen" << std::endl; + + // this causes the segfault, but not sure if compiler might do something else? + // this is just a test, so could maybe make it do sigabrt instead? + volatile int* p = nullptr; + + int v = *p; + + std::cout << "v is:" << v << std::endl; + + std::cout << "this shouldn't print" << std::endl; +} From c65ef282f3becdb4e9bfe88dcb2acf83b98b0196 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Tue, 3 Dec 2024 02:29:32 +0000 Subject: [PATCH 04/13] I think this fixes windows Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 57 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/api/signal_hook.h b/api/signal_hook.h index 3d78f46d4f..d0f644d564 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -4,6 +4,11 @@ #include #include #include + +// from https://man7.org/linux/man-pages/man2/sigaction.2.html +// and https://man7.org/linux/man-pages/man7/feature_test_macros.7.html +#ifdef _POSIX_C_SOURCE + #include #include #include @@ -27,12 +32,25 @@ int add_cleanup_function(void (*f)(int)) { return 0; } + static void bag_handler(int signal); struct BagAbortHook; static BagAbortHook* current_hook; +static int bag_string_length(const char* string) { + int length = 0; + while(true) { + if (string[length] == 0) { + break; + } + length++; + } + + return length; +} + struct BagAbortHook { BagAbortHook* previous; //void (*old_handler[255])(int); @@ -57,19 +75,12 @@ struct BagAbortHook { signal_abbrev = ""; } + // I think this works, it seems to? write needs an fd int stderr_fd = stderr->_fileno; - // strlen is not async signal safe, so it can't be used here - int signal_abbrev_length = 0; - for(;;signal_abbrev_length++) { - if (signal_abbrev[signal_abbrev_length] == 0) { - break; - } - } - - //fputs(", FILE *__restrict stream); - write(stderr_fd, TERM_STRING, sizeof (TERM_STRING) - 1); - write(stderr_fd, signal_abbrev, signal_abbrev_length); + // strlen is not async signal safe, so it can't be used here, but bag_string_length works instead + write(stderr_fd, TERM_STRING, bag_string_length(TERM_STRING)); + write(stderr_fd, signal_abbrev, bag_string_length(signal_abbrev)); write(stderr_fd, "\n", 1); } @@ -176,4 +187,28 @@ static void bag_handler(int signal) { } } +#else // this isn't linux with sigaction, so make a BagAbortHook that does nothing + +static bool bag_warning_printed = false; + +static void print_disabled_warning() { + if (!bag_warning_printed) { + bag_warning_printed = true; + std::cout << "WARNING: BagAbortHook and add_cleanup_function are disabled because _POSIX_C_SOURCE does not say that sigaction is available" << std::endl; + } +} + +int add_cleanup_function(void (*f)(int)) { + print_disabled_warning(); +} + + +class BagAbortHook { + BagAbortHook() { + print_disabled_warning(); + } +}; + +#endif + #endif From 47985656182e7687ca9b9c1c33bcc3e0c1e3c71d Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Tue, 3 Dec 2024 15:59:21 +0000 Subject: [PATCH 05/13] Check if sigabbrev np is there Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/signal_hook.h b/api/signal_hook.h index d0f644d564..4aa06983bb 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -66,7 +66,7 @@ struct BagAbortHook { #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ "the signal that caused this error was: SIG" -#ifdef __USE_GNU +#if defined(__USE_GNU) && defined(_GNU_SOURCE) const char* signal_abbrev = sigabbrev_np(signal); #else const char* signal_abbrev = ""; From e232cac95cda20a0f9079699c2d9efcdc3f83fd0 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 6 Dec 2024 00:06:32 +0000 Subject: [PATCH 06/13] sigabbrev_np is weird Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/api/signal_hook.h b/api/signal_hook.h index 4aa06983bb..ec87f1d69c 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -64,8 +64,27 @@ struct BagAbortHook { char* signal_name; #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ - "the signal that caused this error was: SIG" + "the signal that caused this error was: " + // I can't figure out how to tell if sigabbrev_np exists so I'll + // just print the ones it probably is + const char* signal_abbrev = ""; + + if(signal == SIGSEGV) { + signal_abbrev = "SIGSEGV"; + } else if(signal == SIGABRT) { + signal_abbrev = "SIGABRT"; + } else if(signal == SIGFPE) { + signal_abbrev = "SIGFPE"; + } else if(signal == SIGKILL) { + signal_abbrev = "SIGKILL"; + } else if(signal == SIGILL) { + signal_abbrev = "SIGILL"; + } else if(signal == SIGBUS) { + signal_abbrev = "SIGBUS"; + } + + /* #if defined(__USE_GNU) && defined(_GNU_SOURCE) const char* signal_abbrev = sigabbrev_np(signal); #else @@ -74,6 +93,7 @@ struct BagAbortHook { if (!signal_abbrev) { signal_abbrev = ""; } + */ // I think this works, it seems to? write needs an fd int stderr_fd = stderr->_fileno; @@ -114,8 +134,8 @@ struct BagAbortHook { _exit(-1); } - std::array handled_signals() { - return { SIGABRT, SIGILL, SIGBUS, SIGFPE, SIGSEGV }; + std::array handled_signals() { + return { SIGABRT, SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGKILL }; } BagAbortHook() { From 4dd64d39e881f68f3d6da8510b562b04245358e3 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 6 Dec 2024 03:14:43 +0000 Subject: [PATCH 07/13] fix windows? Signed-off-by: Akshita Mavurapu --- api/bag.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/api/bag.cpp b/api/bag.cpp index 8292305e1d..3a24a13676 100644 --- a/api/bag.cpp +++ b/api/bag.cpp @@ -21,7 +21,6 @@ #include "bag_vrtrackinglist.h" #include #include -#include #ifdef _MSC_VER #pragma warning(push) From 9a82a80900ffe3e9543b27d00a138631b6cc1630 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 6 Dec 2024 14:04:25 +0000 Subject: [PATCH 08/13] Fix windows hook? Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/signal_hook.h b/api/signal_hook.h index ec87f1d69c..dd502faaa8 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -223,7 +223,7 @@ int add_cleanup_function(void (*f)(int)) { } -class BagAbortHook { +struct BagAbortHook { BagAbortHook() { print_disabled_warning(); } From 966d2c537ebc5ed343b0a005cc8d9deb69460642 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 6 Dec 2024 14:07:01 +0000 Subject: [PATCH 09/13] Fix variable error Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/signal_hook.h b/api/signal_hook.h index dd502faaa8..17dec1a308 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -218,7 +218,7 @@ static void print_disabled_warning() { } } -int add_cleanup_function(void (*f)(int)) { +int add_cleanup_function(void (*)(int)) { print_disabled_warning(); } From 55817dba061b9dc36daf6735b6e71e28d1219160 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 6 Dec 2024 14:24:04 +0000 Subject: [PATCH 10/13] Fix error on windows Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 1 + 1 file changed, 1 insertion(+) diff --git a/api/signal_hook.h b/api/signal_hook.h index 17dec1a308..fd9b69adbe 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -220,6 +220,7 @@ static void print_disabled_warning() { int add_cleanup_function(void (*)(int)) { print_disabled_warning(); + return 0; } From d9aaab49e9708902b4441f636c7113bf30355520 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 7 Feb 2025 16:43:29 +0000 Subject: [PATCH 11/13] fix signal hook style issues Signed-off-by: Akshita Mavurapu --- api/signal_hook.h | 51 +++++------------------- tests/CMakeLists.txt | 1 + {examples => tests}/test_signal_hook.cpp | 1 + 3 files changed, 11 insertions(+), 42 deletions(-) rename {examples => tests}/test_signal_hook.cpp (99%) diff --git a/api/signal_hook.h b/api/signal_hook.h index fd9b69adbe..f2376d585b 100644 --- a/api/signal_hook.h +++ b/api/signal_hook.h @@ -16,13 +16,16 @@ #include #include -static void (*cleanup_functions[128])(int); +#define HOOK_HANDLERS_COUNT 255 +#define HOOK_CLEANUP_FUNCTIONS_COUNT 50 + +static void (*cleanup_functions[HOOK_CLEANUP_FUNCTIONS_COUNT])(int); static int cleanup_functions_count = 0; // Returns 0 on success, 1 if too many functions have been set // This is not thread safe, only call it from a single thread int add_cleanup_function(void (*f)(int)) { - if (cleanup_functions_count >= 128) { + if (cleanup_functions_count >= HOOK_CLEANUP_FUNCTIONS_COUNT) { return 1; } @@ -53,18 +56,14 @@ static int bag_string_length(const char* string) { struct BagAbortHook { BagAbortHook* previous; - //void (*old_handler[255])(int); - //void (*current_handler[255])(int); - struct sigaction old_handlers[255]; - //void (*old_handlers[255])(int); + struct sigaction old_handlers[HOOK_HANDLERS_COUNT]; // returns after done printing the exit message void print_error_msg(int signal) { // if the handlers are the same, don't call "bag handler" twice char* signal_name; - #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior\n"\ - "the signal that caused this error was: " + #define TERM_STRING "a critical error occurred within BAG or a dependency (probably libxml or HDF5), exiting to prevent corruption or unexpected behavior. The signal that caused this error was: " // I can't figure out how to tell if sigabbrev_np exists so I'll // just print the ones it probably is @@ -84,18 +83,7 @@ struct BagAbortHook { signal_abbrev = "SIGBUS"; } - /* -#if defined(__USE_GNU) && defined(_GNU_SOURCE) - const char* signal_abbrev = sigabbrev_np(signal); -#else - const char* signal_abbrev = ""; -#endif - if (!signal_abbrev) { - signal_abbrev = ""; - } - */ - - // I think this works, it seems to? write needs an fd + // I think this works, it seems to? write needs a file descriptor int stderr_fd = stderr->_fileno; // strlen is not async signal safe, so it can't be used here, but bag_string_length works instead @@ -105,9 +93,7 @@ struct BagAbortHook { } void call_cleanup_functions(int signal) { - //std::cout << "calling cleanup functions" << std::endl; for(int i = 0; i < cleanup_functions_count; i++) { - //std::cout << "calling cleanup function:" << i << std::endl; cleanup_functions[i](signal); } } @@ -126,11 +112,9 @@ struct BagAbortHook { // if there was a handler before this, that isn't the BAG handler, // call that one - this->call_previous_handler(signal); // if nothing has exited in the previous handlers, exit here - //std::cout << "exiting" << std::endl; _exit(-1); } @@ -139,16 +123,14 @@ struct BagAbortHook { } BagAbortHook() { - std::cout << "made hook" << std::endl; // set these all to null so that when restoring them // we know which ones were added - for (int i = 0; i < 255; i++) { + for (int i = 0; i < HOOK_HANDLERS_COUNT; i++) { this->old_handlers[i].sa_handler = nullptr; } struct sigaction old_action; for (auto sn : this->handled_signals()) { - //std::cout << "setting action for signal " << sn << std::endl; struct sigaction new_action; new_action.sa_flags = 0; new_action.sa_handler = bag_handler; @@ -163,17 +145,6 @@ struct BagAbortHook { // Actually, I think it does support it but apparently signal is // pretty outdated: https://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal auto r = sigaction(sn, &new_action, &old_action); - //auto old_handler = signal(sn, bag_handler); - - /*if (old_handler == SIG_ERR) { - std::cout << "got SIG_ERR setting signal handler?" << std::endl; - } else if (old_handler == SIG_DFL) { - std::cout << "old handler was DFL" << std::endl; - } else if (old_handler == SIG_IGN) { - std::cout << "old handler was IGN" << std::endl; - }*/ - - //std::cout << "setting action returned:" << old_handler << std::endl; this->old_handlers[sn] = old_action; } @@ -182,12 +153,9 @@ struct BagAbortHook { } ~BagAbortHook() { - std::cout << "resetting to original handlers" << std::endl; // reset the handlers back to what they were for (auto sn : this->handled_signals()) { struct sigaction old_action = this->old_handlers[sn]; - //auto old_action = this->old_handlers[sn]; - //signal(sn, old_action); sigaction(sn, &old_action, nullptr); } @@ -196,7 +164,6 @@ struct BagAbortHook { }; static void bag_handler(int signal) { - //std::cout << "handler" << std::endl; if (current_hook) { current_hook->handle(signal); } else { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fd293931c2..b821823476 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -30,6 +30,7 @@ set(TEST_SOURCE_FILES test_bag_vrrefinements.cpp test_bag_vrrefinementsdescriptor.cpp test_bag_vrtrackinglist.cpp + test_signal_hook.cpp ) source_group("Source Files" FILES ${TEST_SOURCE_FILES}) diff --git a/examples/test_signal_hook.cpp b/tests/test_signal_hook.cpp similarity index 99% rename from examples/test_signal_hook.cpp rename to tests/test_signal_hook.cpp index 125fc11cd4..579172ee7f 100644 --- a/examples/test_signal_hook.cpp +++ b/tests/test_signal_hook.cpp @@ -26,6 +26,7 @@ int main(int argc, char** argv) { volatile int* p = nullptr; int v = *p; + std::cout << "v is:" << v << std::endl; From d4ceaaeb1bfb5f326e68240bd3698e80de13d422 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 21 Feb 2025 15:43:47 +0000 Subject: [PATCH 12/13] add more bag signal hooks Signed-off-by: Akshita Mavurapu --- api/bag.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/api/bag.cpp b/api/bag.cpp index 3a24a13676..bc97bf5a43 100644 --- a/api/bag.cpp +++ b/api/bag.cpp @@ -206,6 +206,7 @@ BagError bagCreateFromFile( const char* fileName, const char* metadataFile) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -259,6 +260,7 @@ BagError bagCreateFromBuffer( uint8_t* metadataBuffer, uint32_t metadataBufferSize) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -305,6 +307,7 @@ BagError bagCreateLayer( BagHandle* handle, BAG_LAYER_TYPE type) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -346,6 +349,7 @@ BagError bagGetGridDimensions( uint32_t* rows, uint32_t* cols) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -380,6 +384,7 @@ BagError bagGetSpacing( double* rowSpacing, double* columnSpacing) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -423,6 +428,7 @@ BagError bagGetGeoCover( double* urx, double* ury) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -463,6 +469,7 @@ BagError bagGetMinMaxSimple( float* minValue, float* maxValue) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -500,6 +507,7 @@ BagError bagSetMinMaxSimple( float minValue, float maxValue) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -532,6 +540,7 @@ BagError bagGetNumLayers( BagHandle* handle, uint32_t* numLayers) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -568,6 +577,7 @@ bool bagContainsLayer( const char* layerName, BagError* bagError) { + auto bag_hook = BagAbortHook(); if (!handle) { *bagError = BAG_INVALID_BAG_HANDLE; @@ -630,6 +640,7 @@ BagError bagRead( double* x, double* y) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -699,6 +710,7 @@ BagError bagWrite( const char* layerName, const uint8_t* data) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -745,6 +757,7 @@ BagError bagGetErrorString( BagError code, uint8_t** error) { + auto bag_hook = BagAbortHook(); constexpr int MAX_STR = 255; constexpr int RANK = 2; @@ -983,6 +996,7 @@ BagError bagComputePostion( double* x, double* y) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1021,6 +1035,7 @@ BagError bagComputeIndex( uint32_t* row, uint32_t* col) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1061,6 +1076,7 @@ uint8_t* bagAllocateBuffer( const char* layerName, BagError* bagError) { + auto bag_hook = BagAbortHook(); if (!handle) return {}; @@ -1097,6 +1113,7 @@ uint8_t* bagAllocateBuffer( */ uint8_t* bagAllocate(uint32_t numBytes) { + auto bag_hook = BagAbortHook(); return new uint8_t[numBytes]; } @@ -1107,6 +1124,7 @@ uint8_t* bagAllocate(uint32_t numBytes) */ void bagFree(uint8_t* buffer) { + auto bag_hook = BagAbortHook(); delete[] buffer; } @@ -1132,6 +1150,7 @@ BagError bagReadCorrectorVerticalDatum( uint8_t corrector, uint8_t* datum) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1195,6 +1214,7 @@ BagError bagWriteCorrectorVerticalDatum( uint8_t corrector, const uint8_t* inDatum) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1274,6 +1294,7 @@ BagError bagReadCorrectedLayer( BAG_LAYER_TYPE type, float** data) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1341,6 +1362,7 @@ BagError bagReadCorrectedRegion( BAG_LAYER_TYPE type, float** data) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1390,6 +1412,7 @@ BagError bagReadCorrectedRow( BAG_LAYER_TYPE type, float** data) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1447,6 +1470,7 @@ BagError bagReadCorrectedNode( BAG_LAYER_TYPE type, float** data) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1486,6 +1510,7 @@ BagError bagGetNumSurfaceCorrectors( BagHandle* handle, uint8_t* numCorrectors) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1524,6 +1549,7 @@ BagError bagGetSurfaceCorrectionTopography( BagHandle* handle, BAG_SURFACE_CORRECTION_TOPOGRAPHY* type) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1565,6 +1591,7 @@ BagError bagCreateCorrectorLayer( uint8_t numCorrectors, BAG_SURFACE_CORRECTION_TOPOGRAPHY topography) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1600,6 +1627,7 @@ BagError bagWriteCorrectorDefinition( BagHandle* handle, BagVerticalCorrectorDef* def) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1648,6 +1676,7 @@ BagError bagReadCorrectorDefinition( BagHandle* handle, BagVerticalCorrectorDef* def) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1688,6 +1717,7 @@ BagError bagTrackingListLength( BagHandle* handle, uint32_t* length) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1726,6 +1756,7 @@ BagError bagReadTrackingListNode( BagTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1775,6 +1806,7 @@ BagError bagReadTrackingListCode( BagTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1824,6 +1856,7 @@ BagError bagReadTrackingListSeries( BagTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1866,6 +1899,7 @@ BagError bagWriteTrackingListItem( BagHandle* handle, BagTrackingItem* item) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1900,6 +1934,7 @@ BagError bagWriteTrackingListItem( */ BagError bagSortTrackingListByNode(BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1936,6 +1971,7 @@ BagError bagSortTrackingListByNode(BagHandle* handle) */ BagError bagSortTrackingListBySeries(BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -1972,6 +2008,7 @@ BagError bagSortTrackingListBySeries(BagHandle* handle) */ BagError bagSortTrackingListByCode(BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2008,6 +2045,7 @@ BagError bagSortTrackingListByCode(BagHandle* handle) */ const BagMetadata* bagGetMetaData(BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return nullptr; @@ -2025,6 +2063,7 @@ const BagMetadata* bagGetMetaData(BagHandle* handle) */ BagError bagSetHomeFolder(const char* metadataFolder) { + auto bag_hook = BagAbortHook(); if (!metadataFolder) return BAG_INVALID_FUNCTION_ARGUMENT; @@ -2065,6 +2104,7 @@ BagError bagCreateGeorefMetadataLayer( const FieldDefinition* definition, uint32_t numFields) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2118,7 +2158,10 @@ BagError bagCreateGeorefMetadataLayer( BAG_EXTERNAL BagError bagCreateMetadataProfileGeorefMetadataLayer(BagHandle* handle, BAG_DATA_TYPE indexType, GEOREF_METADATA_PROFILE profile, - const char* layerName) { + + const char* layerName) { + + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2171,6 +2214,7 @@ BagError bagGetGeorefMetadataLayerDefinition( FieldDefinition** definition, uint32_t* numFields) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2226,6 +2270,7 @@ BagError bagGetGeorefMetadataLayerRecords( uint32_t* numRecords, uint32_t* numFields) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2307,6 +2352,7 @@ BagError bagGetGeorefMetadataLayerValueByName( const char* fieldName, BagCompoundDataType* value) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2369,6 +2415,7 @@ BagError bagGetGeorefMetadataLayerValueByIndex( uint32_t fieldIndex, BagCompoundDataType* value) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2427,6 +2474,7 @@ BagError bagGetGeorefMetadataLayerFieldIndex( const char* fieldName, uint32_t* fieldIndex) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2474,6 +2522,7 @@ BagError bagGetGeorefMetadataLayerFieldName( uint32_t fieldIndex, const char** fieldName) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2524,6 +2573,7 @@ BagError bagAddGeorefMetadataLayerRecord( uint32_t numFields, uint32_t* recordIndex) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2589,6 +2639,7 @@ BagError bagAddGeorefMetadataLayerRecords( uint32_t numRecords, uint32_t numFields) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2662,6 +2713,7 @@ BagError bagGeorefMetadataLayerSetValueByName( const char* fieldName, const BagCompoundDataType* value) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2726,6 +2778,7 @@ BagError bagGeorefMetadataLayerSetValueByIndex( uint32_t fieldIndex, const BagCompoundDataType* value) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2781,6 +2834,7 @@ BagError bagCreateVRLayers( BagHandle* handle, bool makeNode) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2831,6 +2885,7 @@ BagError bagVRMetadataGetMinDimensions( uint32_t* minX, uint32_t* minY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2873,6 +2928,7 @@ BagError bagVRMetadataGetMaxDimensions( uint32_t* maxX, uint32_t* maxY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2915,6 +2971,7 @@ BagError bagVRMetadataGetMinResolution( float* minX, float* minY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2957,6 +3014,7 @@ BagError bagVRMetadataGetMaxResolution( float* maxX, float* maxY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -2996,6 +3054,7 @@ BagError bagVRMetadataSetMinDimensions( uint32_t minX, uint32_t minY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3049,6 +3108,7 @@ BagError bagVRMetadataSetMaxDimensions( uint32_t maxX, uint32_t maxY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3102,6 +3162,7 @@ BagError bagVRMetadataSetMinResolution( float minX, float minY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3155,6 +3216,7 @@ BagError bagVRMetadataSetMaxResolution( float maxX, float maxY) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3211,6 +3273,7 @@ BagError bagVRNodeGetMinMaxHypStrength( float* minHypStr, float* maxHypStr) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3252,6 +3315,7 @@ BagError bagVRNodeGetMinMaxNumHypotheses( uint32_t* minNumHyp, uint32_t* maxNumHyp) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3293,6 +3357,7 @@ BagError bagVRNodeGetMinMaxNSamples( uint32_t* minNSamples, uint32_t* maxNSamples) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3332,6 +3397,7 @@ BagError bagVRNodeSetMinMaxHypStrength( float minHypStr, float maxHypStr) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3385,6 +3451,7 @@ BagError bagVRNodeSetMinMaxNumHypotheses( uint32_t minNumHyp, uint32_t maxNumHyp) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3438,6 +3505,7 @@ BagError bagVRNodeSetMinMaxNSamples( uint32_t minNSamples, uint32_t maxNSamples) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3494,6 +3562,7 @@ BAG_EXTERNAL BagError bagVRRefinementGetMinMaxDepth( float* minDepth, float* maxDepth) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3535,6 +3604,7 @@ BAG_EXTERNAL BagError bagVRRefinementGetMinMaxUncertainty( float* minUncert, float* maxUncert) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3574,6 +3644,7 @@ BAG_EXTERNAL BagError bagVRRefinementSetMinMaxDepth( float minDepth, float maxDepth) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3627,6 +3698,7 @@ BAG_EXTERNAL BagError bagVRRefinementSetMinMaxUncertainty( float minUncert, float maxUncert) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3679,6 +3751,7 @@ BagError bagVRTrackingListLength( BagHandle* handle, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3721,6 +3794,7 @@ BagError bagReadVRTrackingListNode( BagVRTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3775,6 +3849,7 @@ BagError bagReadVRTrackingListSubNode( BagVRTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3826,6 +3901,7 @@ BagError bagReadVRTrackingListCode( BagVRTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3877,6 +3953,7 @@ BagError bagReadVRTrackingListSeries( BagVRTrackingItem** items, uint32_t* numItems) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3921,6 +3998,7 @@ BagError bagWriteVRTrackingListItem( BagHandle* handle, BagVRTrackingItem* item) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -3966,6 +4044,7 @@ BagError bagWriteVRTrackingListItem( BagError bagSortVRTrackingListByNode( BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -4013,6 +4092,7 @@ BagError bagSortVRTrackingListByNode( BagError bagSortVRTrackingListBySubNode( BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -4060,6 +4140,7 @@ BagError bagSortVRTrackingListBySubNode( BagError bagSortVRTrackingListBySeries( BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; @@ -4107,6 +4188,7 @@ BagError bagSortVRTrackingListBySeries( BagError bagSortVRTrackingListByCode( BagHandle* handle) { + auto bag_hook = BagAbortHook(); if (!handle) return BAG_INVALID_BAG_HANDLE; From 66dd4fc938be70fb905806b2a8ebfab909d50409 Mon Sep 17 00:00:00 2001 From: Akshita Mavurapu Date: Fri, 28 Feb 2025 12:53:22 +0000 Subject: [PATCH 13/13] remove bag hook from cmakelists Signed-off-by: Akshita Mavurapu --- tests/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b821823476..fd293931c2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -30,7 +30,6 @@ set(TEST_SOURCE_FILES test_bag_vrrefinements.cpp test_bag_vrrefinementsdescriptor.cpp test_bag_vrtrackinglist.cpp - test_signal_hook.cpp ) source_group("Source Files" FILES ${TEST_SOURCE_FILES})