Skip to content

Commit 23a597d

Browse files
Merge pull request #565 from jacobwilliams/563-valgrind-CI
Valgrind CI
2 parents c19763f + 7afba2b commit 23a597d

10 files changed

+113
-19
lines changed

Diff for: .github/workflows/CI.yml

+61-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ubuntu-20.04]
13-
gcc_v: [7,8,9,10] # Version of GFortran we want to use.
14-
python-version: [3.9]
13+
gcc_v: [7,8,9,10,11] # Version of GFortran we want to use.
14+
python-version: [3.11]
1515
env:
1616
FC: gfortran-${{matrix.gcc_v}}
1717
GCC_V: ${{matrix.gcc_v}}
@@ -46,7 +46,7 @@ jobs:
4646
if: contains( matrix.os, 'ubuntu')
4747
run: |
4848
python -m pip install --upgrade pip
49-
pip install ford FoBiS.py pygooglechart
49+
pip install ford FoBiS.py pygooglechart fpm
5050
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
5151
5252
- name: Install GFortran Linux
@@ -60,14 +60,71 @@ jobs:
6060
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
6161
6262
- name: Compile_with_build
63-
if: matrix.gcc_v != 7
63+
if: matrix.gcc_v != 7 && matrix.gcc_v != 11
6464
run: |
6565
GFORTRAN=gfortran-${{matrix.gcc_v}}
6666
GCOV=gcov-${{matrix.gcc_v}}
6767
# build with build.sh, run unit tests
6868
./build.sh --skip-documentation
6969
./build.sh --skip-documentation --enable-unicode
7070
71+
- name: Compile_with_FPM
72+
if: matrix.gcc_v == 11
73+
run: |
74+
GFORTRAN=gfortran-${{matrix.gcc_v}}
75+
GCOV=gcov-${{matrix.gcc_v}}
76+
sudo apt update && sudo apt install -y valgrind
77+
fpm test jf_test_01 --runner "valgrind --leak-check=full --show-leak-kinds=all"
78+
fpm test jf_test_02 --runner "valgrind --leak-check=full --show-leak-kinds=all"
79+
fpm test jf_test_03 --runner "valgrind --leak-check=full --show-leak-kinds=all"
80+
fpm test jf_test_04 --runner "valgrind --leak-check=full --show-leak-kinds=all"
81+
fpm test jf_test_05 --runner "valgrind --leak-check=full --show-leak-kinds=all"
82+
fpm test jf_test_06 --runner "valgrind --leak-check=full --show-leak-kinds=all"
83+
fpm test jf_test_07 --runner "valgrind --leak-check=full --show-leak-kinds=all"
84+
fpm test jf_test_08 --runner "valgrind --leak-check=full --show-leak-kinds=all"
85+
fpm test jf_test_09 --runner "valgrind --leak-check=full --show-leak-kinds=all"
86+
fpm test jf_test_10 --runner "valgrind --leak-check=full --show-leak-kinds=all"
87+
fpm test jf_test_11 --runner "valgrind --leak-check=full --show-leak-kinds=all"
88+
fpm test jf_test_12 --runner "valgrind --leak-check=full --show-leak-kinds=all"
89+
fpm test jf_test_13 --runner "valgrind --leak-check=full --show-leak-kinds=all"
90+
fpm test jf_test_14 --runner "valgrind --leak-check=full --show-leak-kinds=all"
91+
fpm test jf_test_15 --runner "valgrind --leak-check=full --show-leak-kinds=all"
92+
fpm test jf_test_16 --runner "valgrind --leak-check=full --show-leak-kinds=all"
93+
fpm test jf_test_17 --runner "valgrind --leak-check=full --show-leak-kinds=all"
94+
fpm test jf_test_18 --runner "valgrind --leak-check=full --show-leak-kinds=all"
95+
fpm test jf_test_19 --runner "valgrind --leak-check=full --show-leak-kinds=all"
96+
fpm test jf_test_20 --runner "valgrind --leak-check=full --show-leak-kinds=all"
97+
fpm test jf_test_21 --runner "valgrind --leak-check=full --show-leak-kinds=all"
98+
fpm test jf_test_22 --runner "valgrind --leak-check=full --show-leak-kinds=all"
99+
fpm test jf_test_23 --runner "valgrind --leak-check=full --show-leak-kinds=all"
100+
fpm test jf_test_24 --runner "valgrind --leak-check=full --show-leak-kinds=all"
101+
fpm test jf_test_25 --runner "valgrind --leak-check=full --show-leak-kinds=all"
102+
fpm test jf_test_26 --runner "valgrind --leak-check=full --show-leak-kinds=all"
103+
fpm test jf_test_27 --runner "valgrind --leak-check=full --show-leak-kinds=all"
104+
fpm test jf_test_28 --runner "valgrind --leak-check=full --show-leak-kinds=all"
105+
fpm test jf_test_29 --runner "valgrind --leak-check=full --show-leak-kinds=all"
106+
fpm test jf_test_30 --runner "valgrind --leak-check=full --show-leak-kinds=all"
107+
fpm test jf_test_31 --runner "valgrind --leak-check=full --show-leak-kinds=all"
108+
fpm test jf_test_32 --runner "valgrind --leak-check=full --show-leak-kinds=all"
109+
fpm test jf_test_33 --runner "valgrind --leak-check=full --show-leak-kinds=all"
110+
fpm test jf_test_34 --runner "valgrind --leak-check=full --show-leak-kinds=all"
111+
fpm test jf_test_35 --runner "valgrind --leak-check=full --show-leak-kinds=all"
112+
fpm test jf_test_36 --runner "valgrind --leak-check=full --show-leak-kinds=all"
113+
fpm test jf_test_37 --runner "valgrind --leak-check=full --show-leak-kinds=all"
114+
fpm test jf_test_38 --runner "valgrind --leak-check=full --show-leak-kinds=all"
115+
fpm test jf_test_39 --runner "valgrind --leak-check=full --show-leak-kinds=all"
116+
fpm test jf_test_40 --runner "valgrind --leak-check=full --show-leak-kinds=all"
117+
fpm test jf_test_41 --runner "valgrind --leak-check=full --show-leak-kinds=all"
118+
fpm test jf_test_42 --runner "valgrind --leak-check=full --show-leak-kinds=all"
119+
fpm test jf_test_43 --runner "valgrind --leak-check=full --show-leak-kinds=all"
120+
fpm test jf_test_44 --runner "valgrind --leak-check=full --show-leak-kinds=all"
121+
fpm test jf_test_45 --runner "valgrind --leak-check=full --show-leak-kinds=all"
122+
fpm test jf_test_46 --runner "valgrind --leak-check=full --show-leak-kinds=all"
123+
fpm test jf_test_47 --runner "valgrind --leak-check=full --show-leak-kinds=all"
124+
fpm test jf_test_48 --runner "valgrind --leak-check=full --show-leak-kinds=all"
125+
fpm test jf_test_49 --runner "valgrind --leak-check=full --show-leak-kinds=all"
126+
fpm test jf_test_50 --runner "valgrind --leak-check=full --show-leak-kinds=all"
127+
71128
- name: Compile_with_cmake
72129
# CMake build with unit tests, no documentation, with coverage analysis
73130
# No unicode so that coverage combined with the build script will cover unicode

Diff for: src/tests/jf_test_12.F90

+4-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ subroutine test_12(error_cnt)
150150
call json%get(me=root,path='array data.data',array_callback=get_3D_from_array)
151151
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))
152152

153-
my_file = json_file(root,verbose=.true.,real_format='G')
153+
!my_file = json_file(root,verbose=.true.,real_format='G') ! valgrind says this cases a memory leak
154+
call my_file%initialize(verbose=.true.,real_format='G') ! this doesn't have a memmory leak
155+
call my_file%add(root)
156+
nullify(root)
154157

155158
call my_file%update('array data.description',CK_'vector data',found=existed)
156159
call check_file_errors(existed)

Diff for: src/tests/jf_test_15.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ subroutine test_15(error_cnt)
216216

217217
!****************************************
218218

219-
file1 = json_file(p2,json) !constructor
219+
!file1 = json_file(p2,json) ! memory leak with gfortran?
220+
call file1%initialize(json)
221+
call file1%add(p2); nullify(p2)
220222
call file1%destroy(destroy_core=.true.)
221223

222224
!****************************************

Diff for: src/tests/jf_test_25.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ subroutine test_25(error_cnt)
108108
#endif
109109

110110
! test json_file interface
111-
f = json_file(p)
111+
!f = json_file(p) ! memory leak in gfortran?
112+
call f%initialize()
113+
call f%add(p)
112114
nullify(p) ! data is now in f
113115
call f%get('str_array', vec, ilen, found)
114116
if (.not. found) then

Diff for: src/tests/jf_test_27.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ subroutine test_27(error_cnt)
6060
call json%print(p,int(output_unit,IK))
6161

6262
! test json_file interface
63-
f = json_file(p)
63+
!f = json_file(p) ! memory leak in gfortran?
64+
call f%initialize()
65+
call f%add(p)
6466
nullify(p) ! data is now in f
6567
call f%initialize(compress_vectors=.true.)
6668
call f%print()

Diff for: src/tests/jf_test_37.F90

+24-8
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,34 @@ subroutine test_37(error_cnt)
3939
call json%initialize(no_whitespace=.true.)
4040

4141
call json%deserialize(p, CK_'{"a": ["1", "2", "3"]}')
42-
f = json_file(p,no_whitespace=.true.)
42+
!f = json_file(p,no_whitespace=.true.) ! memory leak in gfortran?
43+
call f%initialize(no_whitespace=.true.)
44+
call f%add(p)
4345
call f%print(int(error_unit,IK))
4446
write(error_unit,'(A)') ''
4547
call check_for_error()
4648
call f%destroy()
4749

4850
call json%deserialize(p, CK_'{"b": ["4", "5", "6"]}')
49-
f = json_file(p,json)
51+
!f = json_file(p,json) ! memory leak in gfortran?
52+
call f%initialize(json)
53+
call f%add(p)
5054
call f%print(int(error_unit,IK))
5155
write(error_unit,'(A)') ''
5256
call check_for_error()
5357
call f%destroy()
5458

55-
f = json_file(CK_'{"x": [1,2,3]}',no_whitespace=.true.)
59+
!f = json_file(CK_'{"x": [1,2,3]}',no_whitespace=.true.) ! memory leak in gfortran?
60+
call f%initialize(no_whitespace=.true.)
61+
call f%deserialize(CK_'{"x": [1,2,3]}')
5662
call f%print(int(error_unit,IK))
5763
write(error_unit,'(A)') ''
5864
call check_for_error()
5965
call f%destroy()
6066

61-
f = json_file(CK_'{"y": [4,5,6]}',json)
67+
!f = json_file(CK_'{"y": [4,5,6]}',json) ! memory leak in gfortran?
68+
call f%initialize(json)
69+
call f%deserialize(CK_'{"y": [4,5,6]}')
6270
call f%print(int(error_unit,IK))
6371
write(error_unit,'(A)') ''
6472
call check_for_error()
@@ -69,26 +77,34 @@ subroutine test_37(error_cnt)
6977
! also test default character kind when unicode is enabled:
7078

7179
call json%deserialize(p, CDK_'{"a": ["1", "2", "3"]}')
72-
f = json_file(p,no_whitespace=.true.)
80+
!f = json_file(p,no_whitespace=.true.) ! memory leak in gfortran?
81+
call f%initialize(no_whitespace=.true.)
82+
call f%add(p)
7383
call f%print(int(error_unit,IK))
7484
write(error_unit,'(A)') ''
7585
call check_for_error()
7686
call f%destroy()
7787

7888
call json%deserialize(p, CDK_'{"b": ["4", "5", "6"]}')
79-
f = json_file(p,json)
89+
!f = json_file(p,json) ! memory leak in gfortran?
90+
call f%initialize(json)
91+
call f%add(p)
8092
call f%print(int(error_unit,IK))
8193
write(error_unit,'(A)') ''
8294
call check_for_error()
8395
call f%destroy()
8496

85-
f = json_file(CDK_'{"x": [1,2,3]}',no_whitespace=.true.)
97+
!f = json_file(CDK_'{"x": [1,2,3]}',no_whitespace=.true.) ! memory leak in gfortran?
98+
call f%initialize(no_whitespace=.true.)
99+
call f%deserialize(CDK_'{"x": [1,2,3]}')
86100
call f%print(int(error_unit,IK))
87101
write(error_unit,'(A)') ''
88102
call check_for_error()
89103
call f%destroy()
90104

91-
f = json_file(CDK_'{"y": [4,5,6]}',json)
105+
!f = json_file(CDK_'{"y": [4,5,6]}',json) ! memory leak in gfortran?
106+
call f%initialize(json)
107+
call f%deserialize(CDK_'{"y": [4,5,6]}')
92108
call f%print(int(error_unit,IK))
93109
write(error_unit,'(A)') ''
94110
call check_for_error()

Diff for: src/tests/jf_test_39.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ subroutine test_39(error_cnt)
4444

4545
do i = 1, size(tests)
4646

47-
json = json_file(trim(tests(i)),verbose=.true.,stop_on_error=.true.)
47+
!json = json_file(trim(tests(i)),verbose=.true.,stop_on_error=.true.) ! memory leak in gfortran?
48+
call json%initialize(verbose=.true.,stop_on_error=.true.)
49+
call json%deserialize(trim(tests(i)))
4850
call json%print(int(error_unit,IK))
4951
write(error_unit,'(A)') ''
5052
if (json%failed()) then

Diff for: src/tests/jf_test_41.F90

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ subroutine test_41(error_cnt)
5757
write(error_unit,'(A)') ''
5858
write(error_unit,'(A)') 'copying to json_file...'
5959

60-
f = json_file(p)
60+
!f = json_file(p) ! memory leak in gfortran?
61+
call f%initialize()
62+
call f%add(p)
6163

6264
call f2%add(p2)
6365
nullify(p2) ! data is now in f

Diff for: src/tests/jf_test_46.F90

+2-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ subroutine test_46(error_cnt)
166166
! now, json_file routines:
167167
!---------------------------------
168168

169-
json_f = json_file(str)
169+
!json_f = json_file(str) ! memory leak in gfortran?
170+
call json_f%deserialize(str)
170171

171172
! unicode:
172173
call json_f%get(CK_'not_there', ival, found, default=99_IK)

Diff for: src/tests/jf_test_50.F90

+7
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ subroutine test_50(error_cnt)
3131
type(json_core) :: json
3232
type(json_value),pointer :: p
3333

34+
write(error_unit,'(A)') ''
35+
write(error_unit,'(A)') '================================='
36+
write(error_unit,'(A)') ' EXAMPLE 50'
37+
write(error_unit,'(A)') '================================='
38+
write(error_unit,'(A)') ''
39+
3440
call json%initialize(compress_vectors = .true.) ! so it will print each col on one line
3541

3642
call json%create_object(p,'') !create the root
3743
call json_value_add_real_vec_2d(json, p, CK_'Pcir', pcir, by_col=.true.)
3844
call json%print(p)
45+
call json%destroy(p)
3946

4047
error_cnt = 0
4148

0 commit comments

Comments
 (0)