1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-18 08:53:47 +02:00

Merge pull request #82 from TREX-CoE/fix-memory-leaks

Fix memory leaks and add AddressSanitizer
This commit is contained in:
Anthony Scemama 2022-07-11 11:04:07 +02:00 committed by GitHub
commit ed953cf9b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 4 deletions

View File

@ -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,6 +76,24 @@ jobs:
run: make python-test
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:
#
# runs-on: macos-latest

View File

@ -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 \

View File

@ -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);

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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);