mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 10:06:09 +01:00
Merge pull request #82 from TREX-CoE/fix-memory-leaks
Fix memory leaks and add AddressSanitizer
This commit is contained in:
commit
ed953cf9b6
20
.github/workflows/test-build.yml
vendored
20
.github/workflows/test-build.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
|||||||
./autogen.sh
|
./autogen.sh
|
||||||
mkdir _build
|
mkdir _build
|
||||||
cd _build
|
cd _build
|
||||||
../configure --enable-silent-rules --enable-debug
|
../configure --enable-silent-rules
|
||||||
make -j 4
|
make -j 4
|
||||||
sudo make install
|
sudo make install
|
||||||
|
|
||||||
@ -76,6 +76,24 @@ jobs:
|
|||||||
run: make python-test
|
run: make python-test
|
||||||
working-directory: _build
|
working-directory: _build
|
||||||
|
|
||||||
|
- name: Configure QMCkl in debug mode
|
||||||
|
run: |
|
||||||
|
mkdir _build_debug
|
||||||
|
cd _build_debug
|
||||||
|
../configure --enable-debug --enable-silent-rules
|
||||||
|
make -j2
|
||||||
|
|
||||||
|
- name: Run test
|
||||||
|
run: make -j2 check
|
||||||
|
working-directory: _build_debug
|
||||||
|
|
||||||
|
- name: Archive test log file
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: test-report-ubuntu-debug
|
||||||
|
path: _build_debug/test-suite.log
|
||||||
|
|
||||||
# x86_macos:
|
# x86_macos:
|
||||||
#
|
#
|
||||||
# runs-on: macos-latest
|
# runs-on: macos-latest
|
||||||
|
@ -358,8 +358,10 @@ if test "$ok" = "yes"; then
|
|||||||
if test "$GCC" = "yes"; then
|
if test "$GCC" = "yes"; then
|
||||||
CFLAGS="$CFLAGS \
|
CFLAGS="$CFLAGS \
|
||||||
-g -Wall -W -Wbad-function-cast -Wcast-qual -Warray-bounds -Wdisabled-optimization \
|
-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 \
|
-Wpointer-arith -Wcast-align -Wpedantic -Wextra -Walloc-zero -Werror \
|
||||||
"
|
"
|
||||||
|
LDFLAGS="$LDFLAGS -fsanitize=address"
|
||||||
fi
|
fi
|
||||||
if test "$GFC" = "yes"; then
|
if test "$GFC" = "yes"; then
|
||||||
FCFLAGS="$FCFLAGS \
|
FCFLAGS="$FCFLAGS \
|
||||||
|
@ -2423,6 +2423,7 @@ assert (rc == QMCKL_SUCCESS);
|
|||||||
for (int64_t i=0 ; i < nucl_num ; ++i) {
|
for (int64_t i=0 ; i < nucl_num ; ++i) {
|
||||||
assert(nucleus_shell_num_test[i] == nucleus_shell_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));
|
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);
|
rc = qmckl_get_ao_basis_shell_ang_mom (context, shell_ang_mom_test, shell_num);
|
||||||
|
@ -520,11 +520,13 @@ assert(qmckl_context_check(context) == context);
|
|||||||
assert(qmckl_context_destroy(context) == QMCKL_SUCCESS);
|
assert(qmckl_context_destroy(context) == QMCKL_SUCCESS);
|
||||||
|
|
||||||
/* Check that context is destroyed */
|
/* Check that context is destroyed */
|
||||||
|
#ifndef DEBUG
|
||||||
assert(qmckl_context_check(context) != context);
|
assert(qmckl_context_check(context) != context);
|
||||||
assert(qmckl_context_check(context) == QMCKL_NULL_CONTEXT);
|
assert(qmckl_context_check(context) == QMCKL_NULL_CONTEXT);
|
||||||
|
|
||||||
/* Destroy invalid context */
|
/* Destroy invalid context */
|
||||||
assert(qmckl_context_destroy(QMCKL_NULL_CONTEXT) == QMCKL_INVALID_CONTEXT);
|
assert(qmckl_context_destroy(QMCKL_NULL_CONTEXT) == QMCKL_INVALID_CONTEXT);
|
||||||
|
#endif
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* End of files :noexport:
|
* End of files :noexport:
|
||||||
|
@ -577,6 +577,9 @@ if (x < 0) {
|
|||||||
assert (strcmp(function_name,"qmckl_transpose") == 0);
|
assert (strcmp(function_name,"qmckl_transpose") == 0);
|
||||||
assert (strcmp(message,"Success") == 0);
|
assert (strcmp(message,"Success") == 0);
|
||||||
|
|
||||||
|
exit_code = qmckl_context_destroy(context);
|
||||||
|
assert(exit_code == QMCKL_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -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);
|
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);
|
assert(fabs(dtmp_c[0][1][0][0][0][0] - 0.237440520852232) < 1e-12);
|
||||||
return QMCKL_SUCCESS;
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Electron-electron-nucleus Jastrow \(f_{een}\)
|
** 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);
|
rc = qmckl_get_jastrow_factor_een(context, &(factor_een[0]),walk_num);
|
||||||
|
|
||||||
assert(fabs(factor_een[0] + 0.37407972141304213) < 1e-12);
|
assert(fabs(factor_een[0] + 0.37407972141304213) < 1e-12);
|
||||||
return QMCKL_SUCCESS;
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Electron-electron-nucleus Jastrow \(f_{een}\) derivative
|
** Electron-electron-nucleus Jastrow \(f_{een}\) derivative
|
||||||
|
@ -173,7 +173,7 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
|
|||||||
qmckl_context context = qmckl_context_create();
|
qmckl_context context = qmckl_context_create();
|
||||||
|
|
||||||
qmckl_memory_info_struct info = qmckl_memory_info_struct_zero;
|
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 */
|
/* Allocate an array of ints */
|
||||||
int *a = (int*) qmckl_malloc(context, info);
|
int *a = (int*) qmckl_malloc(context, info);
|
||||||
|
Loading…
Reference in New Issue
Block a user