Skip to content

Commit 03b46ab

Browse files
authored
Merge pull request #448 from LLNL/asan-fixes
Fixes from Address Sanitize (asan)
2 parents bad02ab + 80449a5 commit 03b46ab

58 files changed

Lines changed: 486 additions & 181 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/input.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,15 @@ variable ``void *ptr`` available as the pointer to the memory
549549
to be released.
550550
See :ref:`MemoryManagementAnchor` for details.
551551

552+
.. code-block:: yaml
553+
554+
declarations:
555+
- decl: char *getName() +destructor_name(free_getName)
556+
557+
destructors:
558+
free_getName: |
559+
decref(ptr);
560+
552561
.. and *intent(out)* arguments.
553562
554563
dimension

docs/releases.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ Changes to YAML input
8888
Current use of *+free_pattern* is still supported but will
8989
create a warning message in the logfile. The old usage will be
9090
removed in a future version.
91+
92+
.. code-block:: yaml
93+
94+
declarations:
95+
- decl: char *getName() +destructor_name(free_getName)
96+
97+
destructors:
98+
free_getName: |
99+
decref(ptr);
91100
92101
* Create an abstract interface for typedef statements which
93102
are function pointers. Previously, only function pointers
@@ -300,7 +309,8 @@ F_flatten_namespace flatten_namespace
300309
option:
301310
F_result_as_arg: output
302311
- decl: const char *getConstCharPtrAsCopyArg() +funcarg+deref(copy)
303-
312+
313+
304314
* The **c_helper** and **f_helper** statement fields are merged into **helper**.
305315
A helper may have a C and Fortran part. This required the helper to
306316
be listed twice. Now it only needs to be listed once.

regression/input/char.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,3 @@ patterns:
256256
# return a blank field string if an error occurs
257257
C_invalid_name_buf: |
258258
// Some error code for buf
259-
260-
# This pattern is added to C_memory_dtor_function
261-
# XXX - \t is not dealt with properly
262-
C_string_free: |
263-
// Used with +free_pattern(C_string_free)
264-
std::string *cxx_ptr = reinterpret_cast<std::string *>(ptr);
265-
delete cxx_ptr;

regression/input/cxxlibrary.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ declarations:
125125
declarations:
126126
- decl: int m_length +readonly +name(length);
127127
- decl: Class1()
128+
- decl: ~Class1()
128129

129130
- decl: int check_length(int length = 1)
130131
doxygen:

regression/input/ownership.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ declarations:
102102
# deref: pointer
103103
dimension: len
104104
owner: caller
105-
# C_free_pattern: delete_int_array
105+
destructor_name: delete_int_array
106106
options:
107107
wrap_fortran: False
108108
wrap_lua: False
@@ -113,7 +113,7 @@ declarations:
113113
deref: pointer
114114
dimension: len
115115
owner: caller
116-
# C_free_pattern: delete_int_array
116+
destructor_name: delete_int_array
117117
options:
118118
wrap_lua: False
119119

@@ -122,7 +122,7 @@ declarations:
122122
deref: allocatable
123123
dimension: len
124124
owner: caller
125-
# C_free_pattern: delete_int_array
125+
destructor_name: delete_int_array
126126
options:
127127
wrap_fortran: False
128128
wrap_lua: False
@@ -131,7 +131,7 @@ declarations:
131131
fattrs:
132132
dimension: len
133133
owner: caller
134-
# C_free_pattern: delete_int_array
134+
destructor_name: delete_int_array
135135
options:
136136
wrap_lua: False
137137
# deref("pointer") will be defaulted, return as a Fortran POINTER.
@@ -201,7 +201,7 @@ declarations:
201201
intent: out
202202
deref: raw
203203
owner: caller
204-
# C_free_pattern: delete_int_array
204+
destructor_name: delete_int_array
205205
options:
206206
wrap_c: False
207207
wrap_fortran: False
@@ -215,7 +215,7 @@ declarations:
215215
deref: pointer
216216
dimension: len
217217
owner: caller
218-
# C_free_pattern: delete_int_array
218+
destructor_name: delete_int_array
219219
options:
220220
wrap_c: False
221221
wrap_fortran: False
@@ -229,7 +229,7 @@ declarations:
229229
deref: allocatable
230230
dimension: len
231231
owner: caller
232-
# C_free_pattern: delete_int_array
232+
destructor_name: delete_int_array
233233
options:
234234
wrap_c: False
235235
wrap_fortran: False
@@ -242,7 +242,7 @@ declarations:
242242
intent: out
243243
dimension: len
244244
owner: caller
245-
# C_free_pattern: delete_int_array
245+
destructor_name: delete_int_array
246246
options:
247247
wrap_c: False
248248
wrap_fortran: False
@@ -272,7 +272,7 @@ declarations:
272272

273273

274274

275-
patterns:
275+
destructors:
276276
delete_int_array: |
277277
int * cxx_ptr = reinterpret_cast<int *>(ptr);
278278
delete [] cxx_ptr;

regression/reference/char-cxx-cfi/char.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5472,8 +5472,7 @@
54725472
"language": "cxx",
54735473
"patterns": {
54745474
"C_invalid_name": "if ({cxx_var}.empty()) {{\n return NULL;\n}}\n",
5475-
"C_invalid_name_buf": "// Some error code for buf\n",
5476-
"C_string_free": "// Used with +free_pattern(C_string_free)\nstd::string *cxx_ptr = reinterpret_cast<std::string *>(ptr);\ndelete cxx_ptr;\n"
5475+
"C_invalid_name_buf": "// Some error code for buf\n"
54775476
},
54785477
"scope_file": [
54795478
"char"

regression/reference/char-cxx/char.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6137,8 +6137,7 @@
61376137
"language": "cxx",
61386138
"patterns": {
61396139
"C_invalid_name": "if ({cxx_var}.empty()) {{\n return NULL;\n}}\n",
6140-
"C_invalid_name_buf": "// Some error code for buf\n",
6141-
"C_string_free": "// Used with +free_pattern(C_string_free)\nstd::string *cxx_ptr = reinterpret_cast<std::string *>(ptr);\ndelete cxx_ptr;\n"
6140+
"C_invalid_name_buf": "// Some error code for buf\n"
61426141
},
61436142
"scope_file": [
61446143
"char"

regression/reference/classes/wrapClass1.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ void CLA_Class1_getName_bufferify(CLA_Class1 * self,
368368
ShroudStringToCdesc(SHT_rv_cdesc, &SHC_rv_cxx);
369369
SHT_rv_capsule->addr = const_cast<std::string *>(&SHC_rv_cxx);
370370
SHT_rv_capsule->idtor = 0;
371+
SHT_rv_capsule->cmemflags = SWIG_MEM_RVALUE;
371372
// splicer end class.Class1.method.getName_bufferify
372373
}
373374
// end CLA_Class1_getName_bufferify
@@ -391,6 +392,7 @@ const char * CLA_Class1_getPath(const CLA_Class1 * self,
391392
if (!SHC_rv_cxx->empty()) SHC_rv = SHC_rv_cxx->c_str();
392393
SHT_rv_capsule->addr = SHC_rv_cxx;
393394
SHT_rv_capsule->idtor = 2;
395+
SHT_rv_capsule->cmemflags = SWIG_MEM_RVALUE;
394396
return SHC_rv;
395397
// splicer end class.Class1.method.getPath
396398
}

regression/reference/classes/wrapClass2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void CLA_Class2_getName_bufferify(CLA_Class2 * self,
7676
ShroudStringToCdesc(SHT_rv_cdesc, &SHC_rv_cxx);
7777
SHT_rv_capsule->addr = const_cast<std::string *>(&SHC_rv_cxx);
7878
SHT_rv_capsule->idtor = 0;
79+
SHT_rv_capsule->cmemflags = SWIG_MEM_RVALUE;
7980
// splicer end class.Class2.method.getName_bufferify
8081
}
8182

regression/reference/classes/wrapclasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void CLA_getClass1Copy_bufferify(int flag, CLA_Class1 *SHC_rv)
320320
*SHC_rv_cxx = classes::getClass1Copy(flag);
321321
SHC_rv->addr = SHC_rv_cxx;
322322
SHC_rv->idtor = 1;
323-
SHC_rv->cmemflags = SWIG_MEM_RVALUE;
323+
SHC_rv->cmemflags = SWIG_MEM_OWN | SWIG_MEM_RVALUE;
324324
// splicer end function.getClass1Copy_bufferify
325325
}
326326

0 commit comments

Comments
 (0)