From b6f8363c0ce7a49768d201a00916ca9f8ca632d9 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 13:43:49 +1000 Subject: [PATCH 01/12] LALStatusMacros.h: replace NDEBUG with LAL_ASSERT_MACRO_DISABLED - Document why compiling with this macro set is a bad idea --- lal/lib/std/LALStatusMacros.dox | 48 ++++++++++++++++++--------------- lal/lib/std/LALStatusMacros.h | 4 +-- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lal/lib/std/LALStatusMacros.dox b/lal/lib/std/LALStatusMacros.dox index 8fe5263970..9b10f3959b 100644 --- a/lal/lib/std/LALStatusMacros.dox +++ b/lal/lib/std/LALStatusMacros.dox @@ -493,19 +493,25 @@ code at compile time. Although these flags are typically \#defined or \#undefined globally and can affect many modules, their primary effect is on the debugging and status-reporting tools defined in this header. The two flags are named -\c NDEBUG and \c LAL_STATUS_MACROS_DISABLED. +\c LAL_ASSERT_MACRO_DISABLED and \c LAL_STATUS_MACROS_DISABLED. -\subsection ss_ndebug_flag The NDEBUG flag +\subsection ss_ndebug_flag The LAL_ASSERT_MACRO_DISABLED flag -Compiling with the \c NDEBUG flag set removes all ASSERT() macros from -the object code, in keeping with the philosophy that ASSERT() -statements should only be used to catch coding bugs, not runtime errors. +Compiling with the \c LAL_ASSERT_MACRO_DISABLED flag set removes all +ASSERT() macros from the object code, in keeping with the philosophy +that ASSERT() statements should only be used to catch coding bugs, not +runtime errors. -This is the only purpose for which the \c NDEBUG flag should be used. Code that -checks function input arguments for correctness, reports error messages, -etc. should not be disabled even in production code. The performance impact of -such checks is likely minimal, particularly compared to the human cost of -diagnosing obscure failures in production code because checks/error messages +Compiling with \c LAL_ASSERT_MACRO_DISABLED set is not +recommended. Notwithstanding the philosophy behind ASSERT(), it is +quite likely in places that this macro has been (mis)used for critical checks +without which code will not operate as expected. Correct function with \c +LAL_ASSERT_MACRO_DISABLED set is therefore not guaranteed. + +Code that checks function input arguments for correctness, reports error +messages, etc. should not be disabled even in production code. The performance +impact of such checks is likely minimal, particularly compared to the human cost +of diagnosing obscure failures in production code because checks/error messages were disabled. (Error messages and other diagnostics should use the error-printing functions in \ref LALError_h to selective print messages according to \c lalDebugLevel.) @@ -534,7 +540,7 @@ libraries. When compiling your own modules, the flags can be set using one or more \#define statements within the module or its header file: \code -#define NDEBUG +#define LAL_ASSERT_MACRO_DISABLED #define LAL_STATUS_MACROS_DISABLED \endcode To restrict the scope of these flags, they should later be unset using @@ -544,22 +550,22 @@ Alternatively, these can be set in the \c Makefile or when compiling. The syntax for most UNIX C compilers is something like the following: \code -> gcc ... -DNDEBUG -DLAL_STATUS_MACROS_DISABLED ... +> gcc ... -DLAL_ASSERT_MACRO_DISABLED -DLAL_STATUS_MACROS_DISABLED ... \endcode -If you want to compile a large number of modules, or the entire -library, under the effects of one or more of these flags, you will not -want to go through and modify every header or \c Makefile. -Instead, you may add either -DNDEBUG or -DLAL_STATUS_MACROS_DISABLED -(or both) to the environment variable \c CPPFLAGS. They will then -automatically be set for all compilations done in that environment. -The command for doing this in \c sh or \c bash shells is: +If you want to compile a large number of modules, or the entire library, under +the effects of one or more of these flags, you will not want to go through and +modify every header or \c Makefile. Instead, you may add either +-DLAL_ASSERT_MACRO_DISABLED or -DLAL_STATUS_MACROS_DISABLED +(or both) to the environment variable \c CPPFLAGS. They will then automatically +be set for all compilations done in that environment. The command for doing +this in \c sh or \c bash shells is: \code -> CPPFLAGS="\f$CPPFLAGS -DNDEBUG -DLAL_STATUS_MACROS_DISABLED" +> CPPFLAGS="\f$CPPFLAGS -DLAL_ASSERT_MACRO_DISABLED -DLAL_STATUS_MACROS_DISABLED" \endcode while in \c csh or \c tcsh shells it is: \code -> setenv CPPFLAGS "\f$CPPFLAGS -DNDEBUG -DLAL_STATUS_MACROS_DISABLED" +> setenv CPPFLAGS "\f$CPPFLAGS -DLAL_ASSERT_MACRO_DISABLED -DLAL_STATUS_MACROS_DISABLED" \endcode Note that if you plan to do further LAL code development on the same system, you may want to keep two versions of the library around: one diff --git a/lal/lib/std/LALStatusMacros.h b/lal/lib/std/LALStatusMacros.h index cae109a9bf..117f31b5a4 100644 --- a/lal/lib/std/LALStatusMacros.h +++ b/lal/lib/std/LALStatusMacros.h @@ -113,7 +113,7 @@ extern "C" { return; \ } while ( 0 ) -#ifdef NDEBUG +#ifdef LAL_ASSERT_MACRO_DISABLED #define ASSERT( assertion, statusptr, code, mesg ) #else #define ASSERT( assertion, statusptr, code, mesg ) \ @@ -192,7 +192,7 @@ extern "C" { #define ABORT( statusptr, code, mesg ) \ do { if ( LALPrepareAbort( statusptr, code, mesg, __FILE__, __LINE__ ), 1 ) return; } while ( 0 ) -#ifdef NDEBUG +#ifdef LAL_ASSERT_MACRO_DISABLED #define ASSERT( assertion, statusptr, code, mesg ) #else #define ASSERT( assertion, statusptr, code, mesg ) \ -- GitLab From 358d60d586c66e00958f710daaf7d703eccb5a68 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 13:49:30 +1000 Subject: [PATCH 02/12] FindRoot.c: remove usage of NDEBUG --- lal/lib/utilities/FindRoot.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lal/lib/utilities/FindRoot.c b/lal/lib/utilities/FindRoot.c index 4eaea85b04..f70ca06029 100644 --- a/lal/lib/utilities/FindRoot.c +++ b/lal/lib/utilities/FindRoot.c @@ -66,10 +66,8 @@ LALSBracketRoot ( } /* increment iteration count */ -#ifndef NDEBUG - INT4 imax = 64; + const INT4 imax = 64; ASSERT (i < imax, status, FINDROOTH_EMXIT, FINDROOTH_MSGEMXIT); -#endif ++i; if (fabs(y_1) < fabs(y_2)) @@ -186,10 +184,8 @@ LALDBracketRoot ( } /* increment iteration count */ -#ifndef NDEBUG - INT4 imax = 64; + const INT4 imax = 64; ASSERT (i < imax, status, FINDROOTH_EMXIT, FINDROOTH_MSGEMXIT); -#endif ++i; if (fabs(y_1) < fabs(y_2)) @@ -269,10 +265,8 @@ LALSBisectionFindRoot ( REAL4 ymid; /* increment iteration count */ -#ifndef NDEBUG - INT4 imax = 40; + const INT4 imax = 40; ASSERT (i < imax, status, FINDROOTH_EMXIT, FINDROOTH_MSGEMXIT); -#endif ++i; /* locate midpoint of domain */ @@ -437,10 +431,8 @@ LALDBisectionFindRoot ( REAL8 ymid; /* increment iteration count */ -#ifndef NDEBUG - INT4 imax = 80; + const INT4 imax = 80; ASSERT (i < imax, status, FINDROOTH_EMXIT, FINDROOTH_MSGEMXIT); -#endif ++i; /* locate midpoint of domain */ -- GitLab From 0fd7e3503d31c23215f4b2a48a2c879481194ce2 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 13:49:46 +1000 Subject: [PATCH 03/12] CreateArraySequence_source.c: remove usage of NDEBUG --- lal/lib/factories/CreateArraySequence_source.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lal/lib/factories/CreateArraySequence_source.c b/lal/lib/factories/CreateArraySequence_source.c index 3ef0a15fee..2f487e11f3 100644 --- a/lal/lib/factories/CreateArraySequence_source.c +++ b/lal/lib/factories/CreateArraySequence_source.c @@ -41,13 +41,11 @@ void FUNC ( LALStatus *status, STYPE **aseq, CreateArraySequenceIn *in ) * Use of unsigned for length means we can't check if negative * length was passed */ -#ifndef NDEBUG for ( i = 0; i < in->dimLength->length; i++ ) { ASSERT (in->dimLength->data[i] > 0, status, SEQFACTORIESH_EALENGTH, SEQFACTORIESH_MSGEALENGTH); } -#endif /* * Check return structure: If return pointer does not point to a -- GitLab From 4295301c70dec583b4688c4fbfb97b55d7a565af Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 13:50:25 +1000 Subject: [PATCH 04/12] XLALError.h: fix documentation --- lal/lib/std/XLALError.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lal/lib/std/XLALError.h b/lal/lib/std/XLALError.h index 522eceae38..55789c11e1 100644 --- a/lal/lib/std/XLALError.h +++ b/lal/lib/std/XLALError.h @@ -74,8 +74,7 @@ extern "C" { * * Assert-like error checking can be performed with #XLAL_CHECK-style * macros. Unlike assert() statements, #XLAL_CHECK macros - * do not get removed when the code is not compiled with - * NDEBUG defined. + * do not get removed when the code is compiled with -DNDEBUG. * * Additional error, warning, and informational messages can be generated using * the routines XLALPrintError(), XLALPrintWarning() and -- GitLab From 1eaeeb3be453b0ecbdd335b2cd89cf6c5d3948f1 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 13:56:01 +1000 Subject: [PATCH 05/12] gnuscripts/lalsuite_swig.m4: do not filter out NDEBUG --- gnuscripts/lalsuite_swig.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnuscripts/lalsuite_swig.m4 b/gnuscripts/lalsuite_swig.m4 index 08d6533884..d3c4b479c1 100644 --- a/gnuscripts/lalsuite_swig.m4 +++ b/gnuscripts/lalsuite_swig.m4 @@ -2,7 +2,7 @@ # lalsuite_swig.m4 - SWIG configuration # Author: Karl Wette, 2011--2017 # -# serial 113 +# serial 114 AC_DEFUN([_LALSUITE_MIN_SWIG_VERSION],[ # $0: minimum version of SWIG and other dependencies @@ -606,7 +606,7 @@ EOD`] import sys import distutils.sysconfig as cfg cflags = cfg.get_config_var('CFLAGS').split() -cflags = [f for f in cflags if f != '-DNDEBUG'] +cflags = [f for f in cflags] sys.stdout.write(" ".join(cflags)) EOD`] AS_IF([test $? -ne 0],[ -- GitLab From f933d8a7385cee1c6052c021cf621fde8ce1fb69 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 15:05:57 +1000 Subject: [PATCH 06/12] XLALError.h: new macros XLAL_CHECK_ABORT() and XLAL_CHECK_EXIT() - XLAL_CHECK_ABORT() is intended as replacement for assert() in library code, so lalAbortHook() can be replaced e.g. by SWIG wrappings. No XLAL error code is raised, as either code will abort() or custom lalAbortHook() will be responsible for error - XLAL_CHECK_EXIT() is intended as replacement for assert() in test code, where an immediate exit is fine. --- lal/lib/std/XLALError.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lal/lib/std/XLALError.h b/lal/lib/std/XLALError.h index 55789c11e1..5b0c0f03cf 100644 --- a/lal/lib/std/XLALError.h +++ b/lal/lib/std/XLALError.h @@ -899,6 +899,42 @@ void XLALError(const char *func, */ #define XLAL_CHECK_FAIL(assertion, ...) _XLAL_CHECK_IMPL_(goto XLAL_FAIL, assertion, __VA_ARGS__) +/** + * \brief Macro to test an assertion and invoke a failure if it is not true + * by calling lalAbortHook(). + * + * Prototype: XLAL_CHECK_ABORT(assertion) + * + * \b Parameters:
    + *
  • \b assertion The assertion to test. + *
+ */ +#define XLAL_CHECK_ABORT(assertion) \ + do { \ + if (!(assertion)) { \ + XLAL_PRINT_ERROR("Check failed: %s", #assertion); \ + lalAbortHook("XLAL_CHECK_ABORT() failed"); \ + } \ + } while (0) + +/** + * \brief Macro to test an assertion and invoke a failure if it is not true + * by calling exit(1). + * + * Prototype: XLAL_CHECK_EXIT(assertion) + * + * \b Parameters:
    + *
  • \b assertion The assertion to test. + *
+ */ +#define XLAL_CHECK_EXIT(assertion) \ + do { \ + if (!(assertion)) { \ + XLAL_PRINT_ERROR("Check failed: %s", #assertion); \ + exit(1); \ + } \ + } while (0) + #endif /* SWIG */ -- GitLab From 5a0e7dc402499a1d8740913a06749825aab916c3 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 15:45:56 +1000 Subject: [PATCH 07/12] Use XLAL_CHECK_EXIT() instead of assert() in test code --- lalinference/test/LALInferencePriorTest.c | 1 - lalinference/test/test_cubic_interp.c | 44 +++++++++---------- lalsimulation/test/BHNSRemnantFitsTest.c | 9 ++-- lalsimulation/test/NSBHPropertiesTest.c | 11 +++-- lalsimulation/test/PhenomNSBHTest.c | 25 +++++------ lalsimulation/test/PhenomPTest.c | 15 +++---- .../test/SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c | 3 +- lalsimulation/test/SphHarmTSTest.c | 4 +- 8 files changed, 52 insertions(+), 60 deletions(-) diff --git a/lalinference/test/LALInferencePriorTest.c b/lalinference/test/LALInferencePriorTest.c index c73fc84b34..e71fc05191 100644 --- a/lalinference/test/LALInferencePriorTest.c +++ b/lalinference/test/LALInferencePriorTest.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "LALInferenceTest.h" #define EPSILON 1e-13 diff --git a/lalinference/test/test_cubic_interp.c b/lalinference/test/test_cubic_interp.c index 078f31033d..46550c84ab 100644 --- a/lalinference/test/test_cubic_interp.c +++ b/lalinference/test/test_cubic_interp.c @@ -21,8 +21,8 @@ #include #include #include -#include +#include #ifdef __GNUC__ #define UNUSED __attribute__ ((unused)) @@ -36,7 +36,7 @@ int main(int UNUSED argc, char UNUSED **argv) { static const double data[] = {0, 0, 0, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -50,7 +50,7 @@ int main(int UNUSED argc, char UNUSED **argv) { static const double data[] = {1, 1, 1, 1}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -64,7 +64,7 @@ int main(int UNUSED argc, char UNUSED **argv) { static const double data[] = {1, 0, 1, 4}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -79,7 +79,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { GSL_POSINF, GSL_POSINF, GSL_POSINF, GSL_POSINF}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -94,7 +94,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_POSINF, GSL_POSINF, GSL_POSINF}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -109,7 +109,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { GSL_POSINF, GSL_POSINF, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -124,7 +124,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_POSINF, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -139,7 +139,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, 0, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0.01; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -154,7 +154,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_NEGINF, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); const double result = cubic_interp_eval(interp, 1); cubic_interp_free(interp); const double expected = GSL_POSINF; @@ -166,7 +166,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_POSINF, GSL_NEGINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); const double result = cubic_interp_eval(interp, 0); cubic_interp_free(interp); const double expected = GSL_POSINF; @@ -178,7 +178,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_NEGINF, GSL_NEGINF, GSL_NEGINF}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -193,7 +193,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { GSL_NEGINF, GSL_NEGINF, GSL_NEGINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -208,7 +208,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_NEGINF, GSL_NEGINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -223,7 +223,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, 0, GSL_NEGINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0.01; t <= 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -238,7 +238,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_NEGINF, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); const double result = cubic_interp_eval(interp, 0); cubic_interp_free(interp); const double expected = GSL_NEGINF; @@ -250,7 +250,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_POSINF, GSL_NEGINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); const double result = cubic_interp_eval(interp, 1); cubic_interp_free(interp); const double expected = GSL_NEGINF; @@ -262,7 +262,7 @@ int main(int UNUSED argc, char UNUSED **argv) static const double data[] = { 0, GSL_NEGINF, GSL_POSINF, 0}; cubic_interp *interp = cubic_interp_init(data, 4, -1, 1); - assert(interp); + XLAL_CHECK_EXIT(interp); for (double t = 0.01; t < 1; t += 0.01) { const double result = cubic_interp_eval(interp, t); @@ -296,7 +296,7 @@ int main(int UNUSED argc, char UNUSED **argv) constants[k]); } } - assert(interp); + XLAL_CHECK_EXIT(interp); bicubic_interp_free(interp); } } @@ -320,7 +320,7 @@ int main(int UNUSED argc, char UNUSED **argv) "testing bicubic interpolant for s^%d input", k); } } - assert(interp); + XLAL_CHECK_EXIT(interp); bicubic_interp_free(interp); } @@ -341,7 +341,7 @@ int main(int UNUSED argc, char UNUSED **argv) "testing bicubic interpolant for t^%d input", k); } } - assert(interp); + XLAL_CHECK_EXIT(interp); bicubic_interp_free(interp); } @@ -364,7 +364,7 @@ int main(int UNUSED argc, char UNUSED **argv) k, k); } } - assert(interp); + XLAL_CHECK_EXIT(interp); bicubic_interp_free(interp); } } diff --git a/lalsimulation/test/BHNSRemnantFitsTest.c b/lalsimulation/test/BHNSRemnantFitsTest.c index 5d8a4b4e12..180df24051 100644 --- a/lalsimulation/test/BHNSRemnantFitsTest.c +++ b/lalsimulation/test/BHNSRemnantFitsTest.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +98,7 @@ static void Test_BHNS_spin_aligned(void) { input_BHNS_spin_aligned[i][2], input_BHNS_spin_aligned[i][3]); print_difference("XLALBHNS_spin_aligned", output, expected_BHNS_spin_aligned[i]); - assert(approximatelyEqual(output, expected_BHNS_spin_aligned[i], TOLERANCE_BHNS_SPIN_ALIGNED)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_BHNS_spin_aligned[i], TOLERANCE_BHNS_SPIN_ALIGNED)); } } @@ -140,7 +139,7 @@ static void Test_BHNS_mass_aligned(void) { input_BHNS_mass_aligned[i][2], input_BHNS_mass_aligned[i][3]); print_difference("XLALBHNS_mass_aligned", output, expected_BHNS_mass_aligned[i]); - assert(approximatelyEqual(output, expected_BHNS_mass_aligned[i], TOLERANCE_BHNS_MASS_ALIGNED)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_BHNS_mass_aligned[i], TOLERANCE_BHNS_MASS_ALIGNED)); } } @@ -195,7 +194,7 @@ static void Test_bbh_final_spin_non_precessing_UIB2016(void) { input_bbh_final_spin_non_precessing_UIB2016[i][2], input_bbh_final_spin_non_precessing_UIB2016[i][3]); print_difference("XLALbbh_final_spin_non_precessing_UIB2016", output, expected_bbh_final_spin_non_precessing_UIB2016[i]); - assert(approximatelyEqual(output, expected_bbh_final_spin_non_precessing_UIB2016[i], TOLERANCE_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_bbh_final_spin_non_precessing_UIB2016[i], TOLERANCE_BBH_FINAL_SPIN_NON_PRECESSING_UIB2016)); } } @@ -250,7 +249,7 @@ static void Test_bbh_final_mass_non_precessing_UIB2016(void) { input_bbh_final_mass_non_precessing_UIB2016[i][2], input_bbh_final_mass_non_precessing_UIB2016[i][3]); print_difference("XLALbbh_final_mass_non_precessing_UIB2016", output, expected_bbh_final_mass_non_precessing_UIB2016[i]); - assert(approximatelyEqual(output, expected_bbh_final_mass_non_precessing_UIB2016[i], TOLERANCE_BBH_FINAL_MASS_NON_PRECESSING_UIB2016)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_bbh_final_mass_non_precessing_UIB2016[i], TOLERANCE_BBH_FINAL_MASS_NON_PRECESSING_UIB2016)); } } diff --git a/lalsimulation/test/NSBHPropertiesTest.c b/lalsimulation/test/NSBHPropertiesTest.c index 141e104826..2f6a91f5e6 100644 --- a/lalsimulation/test/NSBHPropertiesTest.c +++ b/lalsimulation/test/NSBHPropertiesTest.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -78,7 +77,7 @@ static void Test_fGWinKerr(void) { input_fGWinKerr[i][1], input_fGWinKerr[i][2]); print_difference("XLALSimNSBH_fGWinKerr", output, expected_fGWinKerr[i]); - assert(approximatelyEqual(output, expected_fGWinKerr[i], TOLERANCE_FGWINKERR)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_fGWinKerr[i], TOLERANCE_FGWINKERR)); } } @@ -96,7 +95,7 @@ static void Test_rKerrISCO(void) { double output = XLALSimNSBH_rKerrISCO( input_rKerrISCO[i][0]); print_difference("XLALSimNSBH_rKerrISCO", output, expected_rKerrISCO[i]); - assert(approximatelyEqual(output, expected_rKerrISCO[i], TOLERANCE_RKERRISCO)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_rKerrISCO[i], TOLERANCE_RKERRISCO)); } } @@ -130,7 +129,7 @@ static void Test_xi_tide(void) { input_xi_tide[i][1], input_xi_tide[i][2]); print_difference("XLALSimNSBH_xi_tide", output, expected_xi_tide[i]); - assert(approximatelyEqual(output, expected_xi_tide[i], TOLERANCE_XI_TIDE)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_xi_tide[i], TOLERANCE_XI_TIDE)); } } @@ -155,7 +154,7 @@ static void Test_compactness_from_lambda(void) { double output = XLALSimNSBH_compactness_from_lambda( input_compactness_from_lambda[i][0]); print_difference("XLALSimNSBH_compactness_from_lambda", output, expected_compactness_from_lambda[i]); - assert(approximatelyEqual(output, expected_compactness_from_lambda[i], TOLERANCE_COMPACTNESS_FROM_LAMBDA)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_compactness_from_lambda[i], TOLERANCE_COMPACTNESS_FROM_LAMBDA)); } } @@ -186,7 +185,7 @@ static void Test_torus_mass_fit(void) { input_torus_mass_fit[i][1], input_torus_mass_fit[i][2]); print_difference("XLALSimNSBH_torus_mass_fit", output, expected_torus_mass_fit[i]); - assert(approximatelyEqual(output, expected_torus_mass_fit[i], TOLERANCE_TORUS_MASS_FIT)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_torus_mass_fit[i], TOLERANCE_TORUS_MASS_FIT)); } } diff --git a/lalsimulation/test/PhenomNSBHTest.c b/lalsimulation/test/PhenomNSBHTest.c index 4a0d2245a2..8149812baa 100644 --- a/lalsimulation/test/PhenomNSBHTest.c +++ b/lalsimulation/test/PhenomNSBHTest.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -103,7 +102,7 @@ static void Test_x_D(void) { input_x_D[i][2], input_x_D[i][3]); print_difference("XLALSimIMRPhenomNSBH_x_D", output, expected_x_D[i]); - assert(approximatelyEqual(output, expected_x_D[i], TOLERANCE_X_D)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_x_D[i], TOLERANCE_X_D)); } } @@ -151,7 +150,7 @@ static void Test_epsilon_ins_with_torus_mass(void) { input_epsilon_ins_with_torus_mass[i][2], input_epsilon_ins_with_torus_mass[i][3]); print_difference("XLALSimIMRPhenomNSBH_epsilon_ins_with_torus_mass", output, expected_epsilon_ins_with_torus_mass[i]); - assert(approximatelyEqual(output, expected_epsilon_ins_with_torus_mass[i], TOLERANCE_EPSILON_INS_WITH_TORUS_MASS)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_epsilon_ins_with_torus_mass[i], TOLERANCE_EPSILON_INS_WITH_TORUS_MASS)); } } @@ -199,7 +198,7 @@ static void Test_x_D_prime(void) { input_x_D_prime[i][2], input_x_D_prime[i][3]); print_difference("XLALSimIMRPhenomNSBH_x_D_prime", output, expected_x_D_prime[i]); - assert(approximatelyEqual(output, expected_x_D_prime[i], TOLERANCE_X_D_PRIME)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_x_D_prime[i], TOLERANCE_X_D_PRIME)); } } @@ -247,7 +246,7 @@ static void Test_sigma_tide_with_torus_mass(void) { input_sigma_tide_with_torus_mass[i][2], input_sigma_tide_with_torus_mass[i][3]); print_difference("XLALSimIMRPhenomNSBH_sigma_tide_with_torus_mass", output, expected_sigma_tide_with_torus_mass[i]); - assert(approximatelyEqual(output, expected_sigma_tide_with_torus_mass[i], TOLERANCE_SIGMA_TIDE_WITH_TORUS_MASS)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_sigma_tide_with_torus_mass[i], TOLERANCE_SIGMA_TIDE_WITH_TORUS_MASS)); } } @@ -325,7 +324,7 @@ static void Test_epsilon_tide_ND(void) { double output = XLALSimIMRPhenomNSBH_epsilon_tide_ND( input_epsilon_tide_ND[i][0]); print_difference("XLALSimIMRPhenomNSBH_epsilon_tide_ND", output, expected_epsilon_tide_ND[i]); - assert(approximatelyEqual(output, expected_epsilon_tide_ND[i], TOLERANCE_EPSILON_TIDE_ND)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_epsilon_tide_ND[i], TOLERANCE_EPSILON_TIDE_ND)); } } @@ -389,7 +388,7 @@ static void Test_sigma_tide_ND(void) { double output = XLALSimIMRPhenomNSBH_sigma_tide_ND( input_sigma_tide_ND[i][0]); print_difference("XLALSimIMRPhenomNSBH_sigma_tide_ND", output, expected_sigma_tide_ND[i]); - assert(approximatelyEqual(output, expected_sigma_tide_ND[i], TOLERANCE_SIGMA_TIDE_ND)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_sigma_tide_ND[i], TOLERANCE_SIGMA_TIDE_ND)); } } @@ -479,7 +478,7 @@ static void Test_x_ND(void) { input_x_ND[i][2], input_x_ND[i][3]); print_difference("XLALSimIMRPhenomNSBH_x_ND", output, expected_x_ND[i]); - assert(approximatelyEqual(output, expected_x_ND[i], TOLERANCE_X_ND)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_x_ND[i], TOLERANCE_X_ND)); } } @@ -569,7 +568,7 @@ static void Test_x_ND_prime(void) { input_x_ND_prime[i][2], input_x_ND_prime[i][3]); print_difference("XLALSimIMRPhenomNSBH_x_ND_prime", output, expected_x_ND_prime[i]); - assert(approximatelyEqual(output, expected_x_ND_prime[i], TOLERANCE_X_ND_PRIME)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_x_ND_prime[i], TOLERANCE_X_ND_PRIME)); } } @@ -589,7 +588,7 @@ static void Test_delta2_prime(void) { input_delta2_prime[i][0], input_delta2_prime[i][1]); print_difference("XLALSimIMRPhenomNSBH_delta2_prime", output, expected_delta2_prime[i]); - assert(approximatelyEqual(output, expected_delta2_prime[i], TOLERANCE_DELTA2_PRIME)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_delta2_prime[i], TOLERANCE_DELTA2_PRIME)); } } @@ -610,7 +609,7 @@ static void Test_baryonic_mass_from_C(void) { input_baryonic_mass_from_C[i][0], input_baryonic_mass_from_C[i][1]); print_difference("XLALSimIMRPhenomNSBH_baryonic_mass_from_C", output, expected_baryonic_mass_from_C[i]); - assert(approximatelyEqual(output, expected_baryonic_mass_from_C[i], TOLERANCE_BARYONIC_MASS_FROM_C)); + XLAL_CHECK_EXIT(approximatelyEqual(output, expected_baryonic_mass_from_C[i], TOLERANCE_BARYONIC_MASS_FROM_C)); } } @@ -634,11 +633,11 @@ static void Test_omega_tilde(void) { // Assert real part is approximately equal print_difference("XLALSimIMRPhenomNSBH_omega_tilde (real)", creal(output), creal(expected_omega_tilde[i])); - assert(approximatelyEqual(creal(output), creal(expected_omega_tilde[i]), TOLERANCE_OMEGA_TILDE)); + XLAL_CHECK_EXIT(approximatelyEqual(creal(output), creal(expected_omega_tilde[i]), TOLERANCE_OMEGA_TILDE)); // Assert imaginary part is approximately equal print_difference("XLALSimIMRPhenomNSBH_omega_tilde (imag)", cimag(output), cimag(expected_omega_tilde[i])); - assert(approximatelyEqual(cimag(output), cimag(expected_omega_tilde[i]), TOLERANCE_OMEGA_TILDE)); + XLAL_CHECK_EXIT(approximatelyEqual(cimag(output), cimag(expected_omega_tilde[i]), TOLERANCE_OMEGA_TILDE)); } } diff --git a/lalsimulation/test/PhenomPTest.c b/lalsimulation/test/PhenomPTest.c index 3e265b431a..9ce8600f80 100644 --- a/lalsimulation/test/PhenomPTest.c +++ b/lalsimulation/test/PhenomPTest.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -194,7 +193,7 @@ static void Test_alpha_epsilon(void) { const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqual(alpha, alpha_expected, eps) && approximatelyEqual(epsilon, epsilon_expected, eps) && "Test_alpha_epsilon()" @@ -257,7 +256,7 @@ static void Test_XLALSimIMRPhenomPCalculateModelParameters(void) { //const REAL8 eps = DBL_EPSILON; const REAL8 eps = 1e-5; - assert(approximatelyEqual(chi_eff, chi_eff_expected, eps) + XLAL_CHECK_EXIT(approximatelyEqual(chi_eff, chi_eff_expected, eps) && approximatelyEqual(chip, chip_expected, eps) && approximatelyEqual(thetaJ, thetaJ_expected, eps) && approximatelyEqual(alpha0, alpha0_expected, eps) @@ -305,7 +304,7 @@ static void Test_PhenomC(void) { const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqualC(hPC, hPC_expected, eps) && "Test_PhenomC()" ); @@ -388,7 +387,7 @@ static void Test_PhenomPCore(void) { COMPLEX16 hc_expected = -9.29441e-23 - I * 2.06616e-23; const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqualC(hp, hp_expected, eps) && approximatelyEqualC(hc, hc_expected, eps) && "Test_PhenomPCore()" @@ -478,7 +477,7 @@ static void Test_XLALSimIMRPhenomP(void) { COMPLEX16 hc_expected = 2.6046e-23 + I * 5.17592e-23; const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqualC(hp, hp_expected, eps) && approximatelyEqualC(hc, hc_expected, eps) && "XLALSimIMRPhenomP()" @@ -610,7 +609,7 @@ static void Test_PhenomC_PhenomP(void) { const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqualC(match, match_expected, eps) && "Test_PhenomC_PhenomP()" ); @@ -757,7 +756,7 @@ static void Test_XLALSimIMRPhenomP_f_ref(void) { const REAL8 eps = 1e-5; - assert( + XLAL_CHECK_EXIT( approximatelyEqualC(hp, hp2, eps) && approximatelyEqualC(hc, hc2, eps) && "XLALSimIMRPhenomP_f_ref()" diff --git a/lalsimulation/test/SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c b/lalsimulation/test/SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c index ced512971d..83bee1d543 100644 --- a/lalsimulation/test/SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c +++ b/lalsimulation/test/SEOBNRv4_ROM_NRTidalv2_NSBH_Test.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -118,7 +117,7 @@ static void Test_amplitude_correction_disruptive(void){ expected_amp_tidal->data[9]=0.8841072573277694; print_difference_FrequencySequence("Amplitude Correction",amp_tidal,expected_amp_tidal,freqs); - assert(approximatelyEqualREAL8Sequence(amp_tidal,expected_amp_tidal,1e-9)); + XLAL_CHECK_EXIT(approximatelyEqualREAL8Sequence(amp_tidal,expected_amp_tidal,1e-9)); } int main(int argc, char *argv[]) { diff --git a/lalsimulation/test/SphHarmTSTest.c b/lalsimulation/test/SphHarmTSTest.c index 1cac191e05..385fb28209 100644 --- a/lalsimulation/test/SphHarmTSTest.c +++ b/lalsimulation/test/SphHarmTSTest.c @@ -26,8 +26,6 @@ */ -#include - #include #include #include @@ -92,7 +90,7 @@ int main(void){ } XLALSphHarmTimeSeriesSetTData( ts, tdata ); REAL8Sequence *tdata_hlm = XLALSphHarmTimeSeriesGetTData( ts ); - assert( tdata_hlm == tdata ); + XLAL_CHECK_EXIT( tdata_hlm == tdata ); XLALDestroySphHarmTimeSeries( ts ); -- GitLab From a7eef061253fe290f506d4dd4ecf50dc1f92506b Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 15:46:33 +1000 Subject: [PATCH 08/12] Use XLAL_CHECK_ABORT() instead of assert() in library code --- lalinference/lib/LALInferenceHDF5.c | 15 +++++++-------- lalinference/lib/LALInferenceInitCBC.c | 3 +-- lalinference/lib/LALInferenceLikelihood.c | 7 +++---- lalinference/lib/distance_integrator.c | 14 ++++++-------- lalsimulation/lib/LALSimFindAttachTime.c | 5 ++--- lalsimulation/lib/LALSimIMRPrecessingNRSur.c | 7 +++---- lalsimulation/lib/LALSimIMRSEOBNRv4TSurrogate.c | 3 +-- lalsimulation/lib/LALSimNRHybSurUtilities.c | 11 +++++------ lalsimulation/lib/LALSimNRSurRemnantUtils.c | 3 +-- 9 files changed, 29 insertions(+), 39 deletions(-) diff --git a/lalinference/lib/LALInferenceHDF5.c b/lalinference/lib/LALInferenceHDF5.c index db69b83440..5411c94728 100644 --- a/lalinference/lib/LALInferenceHDF5.c +++ b/lalinference/lib/LALInferenceHDF5.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -116,9 +115,9 @@ int LALInferenceH5DatasetToVariablesArray( size_t nbytes = XLALH5DatasetQueryNBytes(dataset); char *data = XLALMalloc(nbytes); - assert(data); + XLAL_CHECK_ABORT(data); ret = XLALH5DatasetQueryData(data, dataset); - assert(ret == 0); + XLAL_CHECK_ABORT(ret == 0); LALInferenceVariables **va = NULL; UINT4 Nsamples = XLALH5DatasetQueryNPoints(dataset); @@ -133,7 +132,7 @@ int LALInferenceH5DatasetToVariablesArray( snprintf(pname, sizeof(pname), "FIELD_%d_VARY", i); INT4 value; ret = XLALH5AttributeQueryScalarValue(&value, gdataset, pname); - assert(ret == 0); + XLAL_CHECK_ABORT(ret == 0); vary[i] = value; } @@ -276,7 +275,7 @@ int LALInferenceH5VariablesArrayToDataset( /* Gather together data in one big array */ char *data = XLALCalloc(N, type_size); - assert(data); + XLAL_CHECK_ABORT(data); for (UINT4 i = 0; i < N; i++) { for (UINT4 j = 0; j < Nvary; j++) @@ -290,11 +289,11 @@ int LALInferenceH5VariablesArrayToDataset( /* Create table */ LALH5Dataset *dataset = XLALH5TableAlloc(h5file, TableName, Nvary, column_names, column_types, column_offsets, type_size); - assert(dataset); + XLAL_CHECK_ABORT(dataset); int ret = XLALH5TableAppend( dataset, column_offsets, column_sizes, N, type_size, data); (void) ret; - assert(ret == 0); + XLAL_CHECK_ABORT(ret == 0); XLALFree(data); LALH5Generic gdataset = {.dset = dataset}; @@ -305,7 +304,7 @@ int LALInferenceH5VariablesArrayToDataset( snprintf(pname, sizeof(pname), "FIELD_%d_VARY", i); ret = XLALH5AttributeAddScalar( gdataset, pname, &value, LAL_I4_TYPE_CODE); - assert(ret == 0); + XLAL_CHECK_ABORT(ret == 0); } /* Write attributes, if any */ diff --git a/lalinference/lib/LALInferenceInitCBC.c b/lalinference/lib/LALInferenceInitCBC.c index afd094bd08..4872c405ec 100644 --- a/lalinference/lib/LALInferenceInitCBC.c +++ b/lalinference/lib/LALInferenceInitCBC.c @@ -21,7 +21,6 @@ #include -#include #include #include #include @@ -654,7 +653,7 @@ void LALInferenceRegisterGaussianVariableREAL8(LALInferenceRunState *state, LALI } if((ppt=LALInferenceGetProcParamVal(state->commandLine,valopt))) startval=atof(ppt->value); - assert(stdev>0); + XLAL_CHECK_ABORT(stdev>0); LALInferenceAddVariable(var,name,&startval,LALINFERENCE_REAL8_t,varytype); LALInferenceAddGaussianPrior(state->priorArgs, name, &mean, &stdev, LALINFERENCE_REAL8_t); diff --git a/lalinference/lib/LALInferenceLikelihood.c b/lalinference/lib/LALInferenceLikelihood.c index 05037179f7..5d5e44f943 100644 --- a/lalinference/lib/LALInferenceLikelihood.c +++ b/lalinference/lib/LALInferenceLikelihood.c @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -83,9 +82,9 @@ static int get_calib_spline(LALInferenceVariables *vars, const char *ifoname, RE if(!*logfreqs) *logfreqs = XLALCreateREAL8Vector(npts); if(!*amps) *amps = XLALCreateREAL8Vector(npts); if(!*phases) *phases = XLALCreateREAL8Vector(npts); - assert((*logfreqs)->length==npts); - assert((*amps)->length==npts); - assert((*phases)->length==npts); + XLAL_CHECK_ABORT((*logfreqs)->length==npts); + XLAL_CHECK_ABORT((*amps)->length==npts); + XLAL_CHECK_ABORT((*phases)->length==npts); for(UINT4 i=0;i - #include #include @@ -72,13 +70,13 @@ void dVC_dVL_init(void) { const size_t len = sizeof(dVC_dVL_data) / sizeof(*dVC_dVL_data); dVC_dVL_interp = gsl_spline_alloc(gsl_interp_cspline, len); - assert(dVC_dVL_interp); + XLAL_CHECK_ABORT(dVC_dVL_interp); double x[len]; for (size_t i = 0; i < len; i ++) x[i] = dVC_dVL_tmin + i * dVC_dVL_dt; int ret = gsl_spline_init(dVC_dVL_interp, x, dVC_dVL_data, len); (void) ret; - assert(ret == GSL_SUCCESS); + XLAL_CHECK_ABORT(ret == GSL_SUCCESS); } static double radial_integrand(double r, void *params) @@ -286,12 +284,12 @@ log_radial_integrator *log_radial_integrator_init(double r1, double r2, int k, i double *z1=calloc(size,sizeof(*z1)); double *z2=calloc(size,sizeof(*z2)); double *z0=calloc(size*size,sizeof(*z0)); - assert(z0 && z1 && z2); + XLAL_CHECK_ABORT(z0 && z1 && z2); /* for (size_t i=0;ixmax); + XLAL_CHECK_ABORT(x <= integrator->xmax); if (p == 0) { /* note: p2 == 0 implies b == 0 */ - assert(b == 0); + XLAL_CHECK_ABORT(b == 0); int k1 = integrator->k + 1; if (k1 == 0) diff --git a/lalsimulation/lib/LALSimFindAttachTime.c b/lalsimulation/lib/LALSimFindAttachTime.c index a676029d21..fd5c464cbd 100644 --- a/lalsimulation/lib/LALSimFindAttachTime.c +++ b/lalsimulation/lib/LALSimFindAttachTime.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -42,7 +41,7 @@ double XLALSimLocateOmegaTime( ) { /* check that retLenHi is at least 2 */ - assert( retLenHi > 2 && "retLenHi must be greater than 2" ); + XLAL_CHECK_ABORT( retLenHi > 2 && "retLenHi must be greater than 2" ); *tMaxOmega = 0; //Zach E: Fixes Heisenbug with ICC 16 and 17 compilers (5181); removing this line will result in segfaults with both compilers. /* @@ -445,7 +444,7 @@ double XLALSimLocateAmplTime( unsigned int k; /* check that timeHi->length is at least 2 */ - assert( timeHi->length > 2 && "timeHi->length must be greater than 2" ); + XLAL_CHECK_ABORT( timeHi->length > 2 && "timeHi->length must be greater than 2" ); for (k = 1; k < timeHi->length-1; k++) { ddradiusVec[k] = (radiusVec->data[k+1] - 2.*radiusVec->data[k] + radiusVec->data[k-1])/dt/dt; diff --git a/lalsimulation/lib/LALSimIMRPrecessingNRSur.c b/lalsimulation/lib/LALSimIMRPrecessingNRSur.c index cb07482818..fe2ce6d762 100644 --- a/lalsimulation/lib/LALSimIMRPrecessingNRSur.c +++ b/lalsimulation/lib/LALSimIMRPrecessingNRSur.c @@ -27,7 +27,6 @@ #define UNUSED #endif -#include #include #include #include @@ -295,12 +294,12 @@ static void PrecessingNRSur_LoadFitData( UNUSED size_t nwritten; nwritten = snprintf(tmp_name, str_size, "%s_coefs", name); - assert(nwritten < str_size); + XLAL_CHECK_ABORT(nwritten < str_size); (*fit_data)->coefs = NULL; ReadHDF5RealVectorDataset(sub, tmp_name, &((*fit_data)->coefs)); nwritten = snprintf(tmp_name, str_size, "%s_bfOrders", name); - assert(nwritten < str_size); + XLAL_CHECK_ABORT(nwritten < str_size); (*fit_data)->basisFunctionOrders = NULL; ReadHDF5LongMatrixDataset(sub, tmp_name, &((*fit_data)->basisFunctionOrders)); @@ -329,7 +328,7 @@ static void NRSur7dq4_LoadVectorFitData( for (size_t i=0; ifit_data[i] = fit_data; diff --git a/lalsimulation/lib/LALSimIMRSEOBNRv4TSurrogate.c b/lalsimulation/lib/LALSimIMRSEOBNRv4TSurrogate.c index 93881afaed..7366e543af 100644 --- a/lalsimulation/lib/LALSimIMRSEOBNRv4TSurrogate.c +++ b/lalsimulation/lib/LALSimIMRSEOBNRv4TSurrogate.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -235,7 +234,7 @@ static int TaylorF2Amplitude1PN( UNUSED static void save_gsl_frequency_series(const char filename[], gsl_vector *x, gsl_vector *y) { FILE *fp = fopen(filename, "w"); fprintf(stderr, "save_gsl_frequency_series: %s: %zu %zu\n", filename, x->size, y->size); - assert(x->size == y->size); + XLAL_CHECK_ABORT(x->size == y->size); for (size_t i=0; isize; i++) { fprintf(fp, "%g\t%g\n", gsl_vector_get(x, i), gsl_vector_get(y, i)); } diff --git a/lalsimulation/lib/LALSimNRHybSurUtilities.c b/lalsimulation/lib/LALSimNRHybSurUtilities.c index 5d78af6de1..fd7a5b8b7d 100644 --- a/lalsimulation/lib/LALSimNRHybSurUtilities.c +++ b/lalsimulation/lib/LALSimNRHybSurUtilities.c @@ -37,7 +37,6 @@ #include "LALSimNRHybSurUtilities.h" -#include #include #include #include @@ -164,7 +163,7 @@ static int NRHybSur_LoadDataPiece( for (int i=0; iampl_data_piece, file, sub_grp_name); if(ret != XLAL_SUCCESS) { @@ -300,7 +299,7 @@ static int NRHybSur_LoadSingleModeData( // phase of 22 mode nwritten = snprintf(sub_grp_name, str_size, "l%u_m%u/phase", ell, m); - assert(nwritten < str_size); + XLAL_CHECK_ABORT(nwritten < str_size); ret = NRHybSur_LoadDataPiece(&(data_pieces)->phase_res_data_piece, file, sub_grp_name); if(ret != XLAL_SUCCESS) { @@ -316,7 +315,7 @@ static int NRHybSur_LoadSingleModeData( if (m != 0 || ell % 2 == 0) { // Real part of coorbital frame mode nwritten = snprintf(sub_grp_name, str_size, "l%u_m%u/re", ell, m); - assert(nwritten < str_size); + XLAL_CHECK_ABORT(nwritten < str_size); ret = NRHybSur_LoadDataPiece(&(data_pieces)->coorb_re_data_piece, file, sub_grp_name); if(ret != XLAL_SUCCESS) { @@ -332,7 +331,7 @@ static int NRHybSur_LoadSingleModeData( if (m != 0 || ell % 2 == 1) { // Imaginary part of coorbital frame mode nwritten = snprintf(sub_grp_name, str_size, "l%u_m%u/im", ell, m); - assert(nwritten < str_size); + XLAL_CHECK_ABORT(nwritten < str_size); ret = NRHybSur_LoadDataPiece(&(data_pieces)->coorb_im_data_piece, file, sub_grp_name); if(ret != XLAL_SUCCESS) { diff --git a/lalsimulation/lib/LALSimNRSurRemnantUtils.c b/lalsimulation/lib/LALSimNRSurRemnantUtils.c index 979181f279..35d9a3a502 100644 --- a/lalsimulation/lib/LALSimNRSurRemnantUtils.c +++ b/lalsimulation/lib/LALSimNRSurRemnantUtils.c @@ -36,7 +36,6 @@ #include -#include #include #include #include @@ -220,7 +219,7 @@ int NRSurRemnant_LoadVectorFit( for (UINT4 i=0; i Date: Tue, 30 Aug 2022 15:49:33 +1000 Subject: [PATCH 09/12] Remove assert.h #includes --- lal/lib/vectorops/VectorMath_sse_mathfun_test.c | 1 - lalapps/src/inspiral/blindinj.c | 1 - lalapps/src/inspiral/crinj.c | 1 - lalapps/src/inspiral/inspxmlinj.c | 1 - lalapps/src/inspiral/spininj.c | 1 - lalinference/lib/LALInferenceReadData.c | 1 - lalsimulation/lib/LALSimNRSur3dq8Remnant.c | 1 - lalsimulation/lib/LALSimNRSur7dq4Remnant.c | 1 - 8 files changed, 8 deletions(-) diff --git a/lal/lib/vectorops/VectorMath_sse_mathfun_test.c b/lal/lib/vectorops/VectorMath_sse_mathfun_test.c index 64a37b2113..9a94db1eea 100644 --- a/lal/lib/vectorops/VectorMath_sse_mathfun_test.c +++ b/lal/lib/vectorops/VectorMath_sse_mathfun_test.c @@ -137,7 +137,6 @@ void print4i(__m128i v) { #include #include #include -#include #ifdef HAVE_SYS_TIMES #include diff --git a/lalapps/src/inspiral/blindinj.c b/lalapps/src/inspiral/blindinj.c index 5c576fd567..f049b42e3a 100644 --- a/lalapps/src/inspiral/blindinj.c +++ b/lalapps/src/inspiral/blindinj.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/lalapps/src/inspiral/crinj.c b/lalapps/src/inspiral/crinj.c index 670a7ebce4..c8a1464ba9 100644 --- a/lalapps/src/inspiral/crinj.c +++ b/lalapps/src/inspiral/crinj.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/lalapps/src/inspiral/inspxmlinj.c b/lalapps/src/inspiral/inspxmlinj.c index 47a87880ee..cb385baa56 100644 --- a/lalapps/src/inspiral/inspxmlinj.c +++ b/lalapps/src/inspiral/inspxmlinj.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/lalapps/src/inspiral/spininj.c b/lalapps/src/inspiral/spininj.c index d64d5a2ab8..0553ba1d5a 100644 --- a/lalapps/src/inspiral/spininj.c +++ b/lalapps/src/inspiral/spininj.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/lalinference/lib/LALInferenceReadData.c b/lalinference/lib/LALInferenceReadData.c index d9c4b0d953..2c4c96ec6e 100644 --- a/lalinference/lib/LALInferenceReadData.c +++ b/lalinference/lib/LALInferenceReadData.c @@ -80,7 +80,6 @@ /* LIB deps */ #include #include -#include struct fvec { REAL8 f; diff --git a/lalsimulation/lib/LALSimNRSur3dq8Remnant.c b/lalsimulation/lib/LALSimNRSur3dq8Remnant.c index 25de454c5b..ddcf08a6ee 100644 --- a/lalsimulation/lib/LALSimNRSur3dq8Remnant.c +++ b/lalsimulation/lib/LALSimNRSur3dq8Remnant.c @@ -64,7 +64,6 @@ #include -#include #include #include #include diff --git a/lalsimulation/lib/LALSimNRSur7dq4Remnant.c b/lalsimulation/lib/LALSimNRSur7dq4Remnant.c index 4213783b33..bd3c531ec9 100644 --- a/lalsimulation/lib/LALSimNRSur7dq4Remnant.c +++ b/lalsimulation/lib/LALSimNRSur7dq4Remnant.c @@ -60,7 +60,6 @@ #include -#include #include #include #include -- GitLab From 936af874928a5f5f24d4e03a535b8d7937981f36 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 15:57:44 +1000 Subject: [PATCH 10/12] Build Conda packages without disabling NDEBUG --- .gitlab-ci.yml | 3 --- lal/conda/build.sh | 3 --- lal/conda/install-python.sh | 3 --- lalapps/conda/build.sh | 3 --- lalburst/conda/build.sh | 3 --- lalburst/conda/install-python.sh | 3 --- lalframe/conda/build.sh | 3 --- lalframe/conda/install-python.sh | 3 --- lalinference/conda/build.sh | 3 --- lalinference/conda/install-bin.sh | 3 --- lalinference/conda/install-python.sh | 3 --- lalinspiral/conda/build.sh | 3 --- lalinspiral/conda/install-python.sh | 3 --- lalmetaio/conda/build.sh | 3 --- lalmetaio/conda/install-python.sh | 3 --- lalpulsar/conda/build.sh | 3 --- lalpulsar/conda/install-python.sh | 3 --- lalsimulation/conda/build.sh | 3 --- lalsimulation/conda/install-python.sh | 3 --- 19 files changed, 57 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4c6267308..916e84217d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1698,9 +1698,6 @@ platform:debian:bullseye: "liblal*" "lal*" "python-lal*" - # don't use NDEBUG - - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - - export CONFIGURE_FLAGS="${CONFIGURE_FLAGS} CPPFLAGS='${CPPFLAGS}'" platform:conda:linux: image: igwn/base:conda diff --git a/lal/conda/build.sh b/lal/conda/build.sh index 738017c6f3..6db88f8a9b 100644 --- a/lal/conda/build.sh +++ b/lal/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lal/conda/install-python.sh b/lal/conda/install-python.sh index dd205e884c..6f44c1e6b1 100644 --- a/lal/conda/install-python.sh +++ b/lal/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalapps/conda/build.sh b/lalapps/conda/build.sh index 9905eab6e1..0c5023f40f 100644 --- a/lalapps/conda/build.sh +++ b/lalapps/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalburst/conda/build.sh b/lalburst/conda/build.sh index 2a6c45d253..f2aac0f5d3 100644 --- a/lalburst/conda/build.sh +++ b/lalburst/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalburst/conda/install-python.sh b/lalburst/conda/install-python.sh index 07960c418e..9bf2c0c24c 100644 --- a/lalburst/conda/install-python.sh +++ b/lalburst/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalframe/conda/build.sh b/lalframe/conda/build.sh index a19ea235c8..76965f28b1 100644 --- a/lalframe/conda/build.sh +++ b/lalframe/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalframe/conda/install-python.sh b/lalframe/conda/install-python.sh index daf791b9dc..3361d3de73 100644 --- a/lalframe/conda/install-python.sh +++ b/lalframe/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalinference/conda/build.sh b/lalinference/conda/build.sh index a3133a63b3..dc0d62a94c 100644 --- a/lalinference/conda/build.sh +++ b/lalinference/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalinference/conda/install-bin.sh b/lalinference/conda/install-bin.sh index a5cc14256c..162f46e8fe 100644 --- a/lalinference/conda/install-bin.sh +++ b/lalinference/conda/install-bin.sh @@ -9,9 +9,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalinference/conda/install-python.sh b/lalinference/conda/install-python.sh index 07960c418e..9bf2c0c24c 100755 --- a/lalinference/conda/install-python.sh +++ b/lalinference/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalinspiral/conda/build.sh b/lalinspiral/conda/build.sh index 2a6c45d253..f2aac0f5d3 100644 --- a/lalinspiral/conda/build.sh +++ b/lalinspiral/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalinspiral/conda/install-python.sh b/lalinspiral/conda/install-python.sh index 07960c418e..9bf2c0c24c 100644 --- a/lalinspiral/conda/install-python.sh +++ b/lalinspiral/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalmetaio/conda/build.sh b/lalmetaio/conda/build.sh index a19ea235c8..76965f28b1 100644 --- a/lalmetaio/conda/build.sh +++ b/lalmetaio/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalmetaio/conda/install-python.sh b/lalmetaio/conda/install-python.sh index daf791b9dc..3361d3de73 100644 --- a/lalmetaio/conda/install-python.sh +++ b/lalmetaio/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalpulsar/conda/build.sh b/lalpulsar/conda/build.sh index 8b21cb4cd9..35a0890e6a 100644 --- a/lalpulsar/conda/build.sh +++ b/lalpulsar/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalpulsar/conda/install-python.sh b/lalpulsar/conda/install-python.sh index dff4015de4..e8026a541a 100644 --- a/lalpulsar/conda/install-python.sh +++ b/lalpulsar/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalsimulation/conda/build.sh b/lalsimulation/conda/build.sh index de10cc3bf2..3fd7214160 100644 --- a/lalsimulation/conda/build.sh +++ b/lalsimulation/conda/build.sh @@ -8,9 +8,6 @@ cd _build # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" diff --git a/lalsimulation/conda/install-python.sh b/lalsimulation/conda/install-python.sh index 07960c418e..9bf2c0c24c 100644 --- a/lalsimulation/conda/install-python.sh +++ b/lalsimulation/conda/install-python.sh @@ -13,9 +13,6 @@ cd ${_builddir} # customisation for LALSuite development CI if [[ "${GITLAB_CI}" == "true" ]] && [[ "x${CI_COMMIT_TAG}" == x ]]; then - # allow debugging information - export CPPFLAGS="${CPPFLAGS} -UNDEBUG" - # declare nightly builds if [ "${CI_PIPELINE_SOURCE}" = "schedule" ] || [ "${CI_PIPELINE_SOURCE}" = "web" ]; then CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-nightly" -- GitLab From ef7396950f21c4d2c8411a477ade619a748cc1a7 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 16:39:58 +1000 Subject: [PATCH 11/12] gnuscripts/lalsuite_build.m4: add --enable-strict-defs option - Use #pragma GCC poison to prevent usage of assert(), consistent with LAL spec; see lal/doxygen/src/lal_spec.dox - --enable-strict-defs is not enabled by default, so assert() can always be used for local debugging - Add --enable-strict-defs to CI builds to prevent assert() being used in production code [nightly ci] --- .gitlab-ci.yml | 3 ++- gnuscripts/lalsuite_build.m4 | 21 ++++++++++++++++++++- gnuscripts/lalsuite_swig.m4 | 6 +++--- lal/configure.ac | 1 + lal/lib/std/LALStddef.h | 11 ++++++++++- lalapps/configure.ac | 1 + lalburst/configure.ac | 3 +++ lalframe/configure.ac | 3 +++ lalinference/configure.ac | 3 +++ lalinspiral/configure.ac | 3 +++ lalmetaio/configure.ac | 3 +++ lalpulsar/configure.ac | 3 +++ lalsimulation/configure.ac | 3 +++ 13 files changed, 58 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 916e84217d..3da47c45e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -169,7 +169,8 @@ default: - ./00boot # we use xargs here in case CONFIGURE_FLAGS contains # variables with spaces, etc etc - - xargs ./configure ${ENABLE_NIGHTLY} <<< ${CONFIGURE_FLAGS} + - DEFAULT_CONFIGURE_FLAGS="--enable-strict-defs ${ENABLE_NIGHTLY}" + - xargs ./configure ${DEFAULT_CONFIGURE_FLAGS} <<< ${CONFIGURE_FLAGS} - make -j${CPU_COUNT} VERBOSE=1 ${MAKE_TARGET:-distcheck} artifacts: # upload some files to debug failures diff --git a/gnuscripts/lalsuite_build.m4 b/gnuscripts/lalsuite_build.m4 index ae17aaa27d..be00f2b681 100644 --- a/gnuscripts/lalsuite_build.m4 +++ b/gnuscripts/lalsuite_build.m4 @@ -1,7 +1,7 @@ # -*- mode: autoconf; -*- # lalsuite_build.m4 - top level build macros # -# serial 168 +# serial 169 # restrict which LALSUITE_... patterns can appearing in output (./configure); # useful for debugging problems with unexpanded LALSUITE_... Autoconf macros @@ -360,6 +360,25 @@ AC_DEFUN([LALSUITE_ADD_TESTS_ENV_CONFIG_VAR],[ ]) ]) +AC_DEFUN([LALSUITE_ENABLE_STRICT_DEFS],[ + # $0: forbid certain definitions in LAL code + AC_ARG_ENABLE( + [strict-defs], + AS_HELP_STRING( + [--enable-strict-defs], + [forbid certain definitions in LAL code [default=no]] + ),[ + AS_CASE(["${enableval}"], + [yes],[LALSUITE_ADD_FLAGS([C],[-DLAL_STRICT_DEFS_ENABLED])], + [no],[:], + [AC_MSG_ERROR([bad value for ${enableval} for --enable-strict-defs])] + ) + ],[ + ] + ) + # end $0 +]) + AC_DEFUN([LALSUITE_REQUIRE_CXX],[ # $0: require a C++ compiler lalsuite_require_cxx=true diff --git a/gnuscripts/lalsuite_swig.m4 b/gnuscripts/lalsuite_swig.m4 index d3c4b479c1..83d91deeb9 100644 --- a/gnuscripts/lalsuite_swig.m4 +++ b/gnuscripts/lalsuite_swig.m4 @@ -2,7 +2,7 @@ # lalsuite_swig.m4 - SWIG configuration # Author: Karl Wette, 2011--2017 # -# serial 114 +# serial 115 AC_DEFUN([_LALSUITE_MIN_SWIG_VERSION],[ # $0: minimum version of SWIG and other dependencies @@ -464,7 +464,7 @@ EOF AC_MSG_NOTICE([Octave modules will be compiled with ${abiflag:-no _GLIBCXX_USE_CXX11_ABI flag}]) # determine Octave preprocessor flags - AC_SUBST([SWIG_OCTAVE_CPPFLAGS],["${abiflag}"]) + AC_SUBST([SWIG_OCTAVE_CPPFLAGS],["-ULAL_STRICT_DEFS_ENABLED ${abiflag}"]) AC_SUBST([SWIG_OCTAVE_CPPFLAGS_IOCTAVE],[]) for arg in CPPFLAGS INCFLAGS; do for flag in `${mkoctfile} -p ${arg} 2>/dev/null`; do @@ -584,7 +584,7 @@ EOD`] ]) # determine Python preprocessor flags - AC_SUBST([SWIG_PYTHON_CPPFLAGS],[]) + AC_SUBST([SWIG_PYTHON_CPPFLAGS],["-ULAL_STRICT_DEFS_ENABLED"]) python_out=[`cat </dev/null import sys import distutils.sysconfig as cfg diff --git a/lal/configure.ac b/lal/configure.ac index c7ed9d6d80..93f70fae43 100644 --- a/lal/configure.ac +++ b/lal/configure.ac @@ -133,6 +133,7 @@ LAL_ENABLE_INTELFFT LAL_ENABLE_FFTW3_MEMALIGN LALSUITE_ENABLE_GCC_FLAGS +LALSUITE_ENABLE_STRICT_DEFS LAL_WITH_DEFAULT_DEBUG_LEVEL LAL_WITH_DATA_PATH diff --git a/lal/lib/std/LALStddef.h b/lal/lib/std/LALStddef.h index fe7483ce1f..5fd27ae578 100644 --- a/lal/lib/std/LALStddef.h +++ b/lal/lib/std/LALStddef.h @@ -1,5 +1,5 @@ /* -* Copyright (C) 2014 Karl Wette +* Copyright (C) 2014, 2020 Karl Wette * Copyright (C) 2013 Jolien Creighton * * This program is free software; you can redistribute it and/or modify @@ -21,6 +21,15 @@ #ifndef _LALSTDDEF_H #define _LALSTDDEF_H +/* forbid certain definitions in LAL code */ +#if defined(LAL_STRICT_DEFS_ENABLED) +# if defined(__GNUC__) +/* assert() is often misused for error-checking code + which should never be disabled in production usage */ +# pragma GCC poison assert +# endif +#endif + /* macros for certain keywords */ #if __STDC_VERSION__ >= 199901L # define _LAL_RESTRICT_ restrict diff --git a/lalapps/configure.ac b/lalapps/configure.ac index 98017f862f..98ca928ecf 100644 --- a/lalapps/configure.ac +++ b/lalapps/configure.ac @@ -73,6 +73,7 @@ LALSUITE_CHECK_GIT_REPO LALSUITE_DISTCHECK_CONFIGURE_FLAGS LALSUITE_ENABLE_GCC_FLAGS +LALSUITE_ENABLE_STRICT_DEFS LALSUITE_ENABLE_NIGHTLY LALAPPS_ENABLE_CONDOR LALAPPS_ENABLE_STATIC_BINARIES diff --git a/lalburst/configure.ac b/lalburst/configure.ac index f73e35d544..fa4afde510 100644 --- a/lalburst/configure.ac +++ b/lalburst/configure.ac @@ -90,6 +90,9 @@ LALSUITE_ENABLE_NIGHTLY # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # enable SWIG wrapping modules LALSUITE_ENABLE_SWIG diff --git a/lalframe/configure.ac b/lalframe/configure.ac index 25584fe9ca..43080464a0 100644 --- a/lalframe/configure.ac +++ b/lalframe/configure.ac @@ -95,6 +95,9 @@ LALFRAME_ENABLE_FRAMEL # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # enable SWIG wrapping modules LALSUITE_ENABLE_SWIG diff --git a/lalinference/configure.ac b/lalinference/configure.ac index fe763bd420..02570c933e 100644 --- a/lalinference/configure.ac +++ b/lalinference/configure.ac @@ -108,6 +108,9 @@ LALSUITE_ENABLE_MPI # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # optional lal libraries LALSUITE_ENABLE_LALFRAME LALSUITE_ENABLE_LALMETAIO diff --git a/lalinspiral/configure.ac b/lalinspiral/configure.ac index 91dd8c3abe..648ac0f701 100644 --- a/lalinspiral/configure.ac +++ b/lalinspiral/configure.ac @@ -93,6 +93,9 @@ LALSUITE_ENABLE_NIGHTLY # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # enable SWIG wrapping modules LALSUITE_ENABLE_SWIG diff --git a/lalmetaio/configure.ac b/lalmetaio/configure.ac index efb45d6156..dbf14aacf8 100644 --- a/lalmetaio/configure.ac +++ b/lalmetaio/configure.ac @@ -84,6 +84,9 @@ LALSUITE_ENABLE_NIGHTLY # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # enable SWIG wrapping modules LALSUITE_ENABLE_SWIG diff --git a/lalpulsar/configure.ac b/lalpulsar/configure.ac index 17d98adcc3..9d3d5beff6 100644 --- a/lalpulsar/configure.ac +++ b/lalpulsar/configure.ac @@ -117,6 +117,9 @@ LALPULSAR_ENABLE_SISTR # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # optional lal libraries LALSUITE_ENABLE_LALFRAME LALSUITE_ENABLE_LALSIMULATION diff --git a/lalsimulation/configure.ac b/lalsimulation/configure.ac index 26808075ff..bec36f02da 100644 --- a/lalsimulation/configure.ac +++ b/lalsimulation/configure.ac @@ -88,6 +88,9 @@ LALSUITE_ENABLE_NIGHTLY # enable strict gcc flags LALSUITE_ENABLE_GCC_FLAGS +# enable strict definitions +LALSUITE_ENABLE_STRICT_DEFS + # enable SWIG wrapping modules LALSUITE_ENABLE_SWIG -- GitLab From 63f9fdd7480e439a6a0da67a0bcefc29154ef2bb Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 30 Aug 2022 19:12:32 +1000 Subject: [PATCH 12/12] LALSimFindAttachTime.c: ensure ddradiusVec arrays are initialised - Fixes warnings with GCC 11, which is smart enough to interpret the (former) assert(retLenHi > 2) statement as requiring that this array must have at least 2 elements -- except that if the assert() is compiled away with -DNDEBUG this check is never performed [nightly ci] --- lalsimulation/lib/LALSimFindAttachTime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lalsimulation/lib/LALSimFindAttachTime.c b/lalsimulation/lib/LALSimFindAttachTime.c index fd5c464cbd..740267cc07 100644 --- a/lalsimulation/lib/LALSimFindAttachTime.c +++ b/lalsimulation/lib/LALSimFindAttachTime.c @@ -82,7 +82,7 @@ double XLALSimLocateOmegaTime( timeHi.data = dynamicsHi->data; double dt = timeHi.data[1] - timeHi.data[0]; - double ddradiusVec[timeHi.length - 1]; + double XLAL_INIT_DECL(ddradiusVec, [timeHi.length - 1]); unsigned int k; for (k = 1; k < timeHi.length-1; k++) { ddradiusVec[k] = (radiusVec->data[k+1] - 2.*radiusVec->data[k] + radiusVec->data[k-1])/dt/dt; @@ -440,7 +440,7 @@ double XLALSimLocateAmplTime( if (debugPK) {debugRD = 0;} double dt = timeHi->data[1] - timeHi->data[0]; - double ddradiusVec[timeHi->length - 1]; + double XLAL_INIT_DECL(ddradiusVec, [timeHi->length - 1]); unsigned int k; /* check that timeHi->length is at least 2 */ -- GitLab