From daf85efe675bd6bb4a7f2d4a5fbbfdf321d06bd3 Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 8 Jul 2022 17:43:11 +0200 Subject: [PATCH 1/9] Fix some memory leaks in the tests --- org/qmckl_ao.org | 1 + org/qmckl_error.org | 3 +++ 2 files changed, 4 insertions(+) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index f50dd1c..47877b7 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -2423,6 +2423,7 @@ assert (rc == QMCKL_SUCCESS); for (int64_t i=0 ; i < nucl_num ; ++i) { assert(nucleus_shell_num_test[i] == nucleus_shell_num[i]); } +free(nucleus_shell_num_test); shell_ang_mom_test = (int32_t*) malloc ( shell_num * sizeof(int32_t)); rc = qmckl_get_ao_basis_shell_ang_mom (context, shell_ang_mom_test, shell_num); diff --git a/org/qmckl_error.org b/org/qmckl_error.org index 25721d1..e52f429 100644 --- a/org/qmckl_error.org +++ b/org/qmckl_error.org @@ -577,6 +577,9 @@ if (x < 0) { assert (strcmp(function_name,"qmckl_transpose") == 0); assert (strcmp(message,"Success") == 0); + exit_code = qmckl_context_destroy(context); + assert(exit_code == QMCKL_SUCCESS); + return 0; } #+end_src From f1f83d1582e1a71c1a6f8ea1be580efd5588ded2 Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 8 Jul 2022 17:52:34 +0200 Subject: [PATCH 2/9] Include the CI steps with AddressSanitizer --- .github/workflows/test-build.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 16b32ce..0ff42eb 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -76,6 +76,24 @@ jobs: run: make python-test working-directory: _build + - name: Re-build QMCkl with AddressSanitizer + run: | + mkdir _build_as + cd _build_as + ../configure CFLAGS="-g -O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules + make -j2 + + - name: Run test + run: make -j2 check + working-directory: _build_as + + - name: Archive test log file + if: failure() + uses: actions/upload-artifact@v2 + with: + name: test-report-ubuntu-as + path: _build_as/test-suite.log + # x86_macos: # # runs-on: macos-latest From 062e06693a58d4858a0838f1e0a931ae61fd82b3 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 09:46:13 +0200 Subject: [PATCH 3/9] Fix qmckl_memory test --- org/qmckl_memory.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_memory.org b/org/qmckl_memory.org index acf2433..fc64322 100644 --- a/org/qmckl_memory.org +++ b/org/qmckl_memory.org @@ -173,7 +173,7 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) { qmckl_context context = qmckl_context_create(); qmckl_memory_info_struct info = qmckl_memory_info_struct_zero; -info.size = (size_t) 3; +info.size = (size_t) 3*sizeof(int); /* Allocate an array of ints */ int *a = (int*) qmckl_malloc(context, info); From cdd3d91e3a8a5b0eff5da5089e8c4a3938897cf5 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:09:34 +0200 Subject: [PATCH 4/9] Fix Jastrow test --- org/qmckl_jastrow.org | 2 -- 1 file changed, 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index ca94399..1dddc27 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -6942,7 +6942,6 @@ assert(fabs(tmp_c[0][0][1][0][0] - 2.7083473948352403) < 1e-12); printf("%e\n%e\n", tmp_c[0][1][0][0][0],0.237440520852232); assert(fabs(dtmp_c[0][1][0][0][0][0] - 0.237440520852232) < 1e-12); -return QMCKL_SUCCESS; #+end_src ** Electron-electron-nucleus Jastrow \(f_{een}\) @@ -7441,7 +7440,6 @@ double factor_een[walk_num]; rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0]),walk_num); assert(fabs(factor_een[0] + 0.37407972141304213) < 1e-12); -return QMCKL_SUCCESS; #+end_src ** Electron-electron-nucleus Jastrow \(f_{een}\) derivative From 9ec3d19777d4cc119b03354bf886209601f46f56 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:20:50 +0200 Subject: [PATCH 5/9] Add AddressSanitizer to the debug configure --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index e8e09c6..2b32656 100644 --- a/configure.ac +++ b/configure.ac @@ -358,8 +358,10 @@ if test "$ok" = "yes"; then if test "$GCC" = "yes"; then CFLAGS="$CFLAGS \ -g -Wall -W -Wbad-function-cast -Wcast-qual -Warray-bounds -Wdisabled-optimization \ +-fsanitize=address -fno-omit-frame-pointer \ -Wpointer-arith -Wcast-align -Wpedantic -Wextra -Walloc-zero -Werror \ " + LDFLAGS="$LDFLAGS -fsanitize=address" fi if test "$GFC" = "yes"; then FCFLAGS="$FCFLAGS \ From 1600041f6c13ae7983c0b95368524b40a0ee1cfc Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:21:16 +0200 Subject: [PATCH 6/9] Fix the qmckl_context test to pass in DEBUG mode --- org/qmckl_context.org | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org/qmckl_context.org b/org/qmckl_context.org index 9054ba1..33020d0 100644 --- a/org/qmckl_context.org +++ b/org/qmckl_context.org @@ -520,11 +520,13 @@ assert(qmckl_context_check(context) == context); assert(qmckl_context_destroy(context) == QMCKL_SUCCESS); /* Check that context is destroyed */ +#ifndef DEBUG assert(qmckl_context_check(context) != context); assert(qmckl_context_check(context) == QMCKL_NULL_CONTEXT); /* Destroy invalid context */ assert(qmckl_context_destroy(QMCKL_NULL_CONTEXT) == QMCKL_INVALID_CONTEXT); +#endif #+end_src * End of files :noexport: From de367f9126fadfa0c3e87be3a4eea980d04d30b4 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:31:40 +0200 Subject: [PATCH 7/9] AddressSanitizer is now included in the DEBUG build --- .github/workflows/test-build.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 0ff42eb..5c65b0d 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -76,23 +76,6 @@ jobs: run: make python-test working-directory: _build - - name: Re-build QMCkl with AddressSanitizer - run: | - mkdir _build_as - cd _build_as - ../configure CFLAGS="-g -O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules - make -j2 - - - name: Run test - run: make -j2 check - working-directory: _build_as - - - name: Archive test log file - if: failure() - uses: actions/upload-artifact@v2 - with: - name: test-report-ubuntu-as - path: _build_as/test-suite.log # x86_macos: # From c4205ed2f833d4f09ab18944468e400d6369a166 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:36:37 +0200 Subject: [PATCH 8/9] Revert "AddressSanitizer is now included in the DEBUG build" This reverts commit de367f9126fadfa0c3e87be3a4eea980d04d30b4. --- .github/workflows/test-build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 5c65b0d..0ff42eb 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -76,6 +76,23 @@ jobs: run: make python-test working-directory: _build + - name: Re-build QMCkl with AddressSanitizer + run: | + mkdir _build_as + cd _build_as + ../configure CFLAGS="-g -O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules + make -j2 + + - name: Run test + run: make -j2 check + working-directory: _build_as + + - name: Archive test log file + if: failure() + uses: actions/upload-artifact@v2 + with: + name: test-report-ubuntu-as + path: _build_as/test-suite.log # x86_macos: # From df2db1bd2a042828129d53e3e4d58d38c58f94cd Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 11 Jul 2022 10:38:39 +0200 Subject: [PATCH 9/9] Separate basic and debug builds in CI --- .github/workflows/test-build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 0ff42eb..4d48e55 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -40,7 +40,7 @@ jobs: ./autogen.sh mkdir _build cd _build - ../configure --enable-silent-rules --enable-debug + ../configure --enable-silent-rules make -j 4 sudo make install @@ -76,23 +76,23 @@ jobs: run: make python-test working-directory: _build - - name: Re-build QMCkl with AddressSanitizer + - name: Configure QMCkl in debug mode run: | - mkdir _build_as - cd _build_as - ../configure CFLAGS="-g -O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules + mkdir _build_debug + cd _build_debug + ../configure --enable-debug --enable-silent-rules make -j2 - name: Run test run: make -j2 check - working-directory: _build_as + working-directory: _build_debug - name: Archive test log file if: failure() uses: actions/upload-artifact@v2 with: - name: test-report-ubuntu-as - path: _build_as/test-suite.log + name: test-report-ubuntu-debug + path: _build_debug/test-suite.log # x86_macos: #