Skip to content

Commit 3e921e2

Browse files
Merge pull request #794 from baagaard-usgs/feature-sanitize-configure-option
Add ability to build library with -fsanitize=address to help detect memory errors
2 parents 218ecb1 + 2b15aae commit 3e921e2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ AC_ARG_WITH([python-coverage],
4848
[python_coverage="coverage2"])
4949
AC_SUBST(python_coverage)
5050

51+
dnl sanitizer
52+
AC_ARG_ENABLE([sanitizer],
53+
[AC_HELP_STRING([--enable-sanitizer],
54+
[enable compiling C++ code with -fsanitizer @<:@default=no@:>@])],
55+
[if test "$enableval" != no; then enable_sanitizer=yes; else enable_sanitizer=no; fi;
56+
if test "$enableval" = yes; then sanitizer=address; else sanitizer=$enableval; fi],
57+
[enable_sanitizer=no])
58+
if test "$enable_sanitizer" = "yes"; then
59+
SANITIZER_CXXFLAGS="-fsanitize=$sanitizer"; export SANITIZER_CXXFLAGS
60+
fi
61+
AC_SUBST(SANITIZER_CXXFLAGS)
62+
5163
dnl CUBIT I/O w/netcdf
5264
AC_ARG_ENABLE([cubit],
5365
[AC_HELP_STRING([--enable-cubit],

libsrc/pylith/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ libpylith_la_SOURCES = \
146146
utils/TestArray.cc
147147

148148

149-
149+
libpylith_la_CXXFLAGS = $(SANITIZER_CXXFLAGS)
150150
libpylith_la_LDFLAGS = $(AM_LDFLAGS) $(PYTHON_LDFLAGS) $(PYTHON_LA_LDFLAGS)
151151
libpylith_la_LIBADD = \
152152
-lspatialdata \

libsrc/pylith/topology/Field.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ pylith::topology::Field::getSubfieldNames(void) const {
590590
names[sinfo.index] = s_iter->first;
591591
} // for
592592

593-
PYLITH_METHOD_RETURN(pylith::string_vector(names));
593+
PYLITH_METHOD_RETURN(names);
594594
} // subfieldNames
595595

596596

@@ -599,6 +599,7 @@ pylith::topology::Field::getSubfieldNames(void) const {
599599
const pylith::topology::Field::SubfieldInfo&
600600
pylith::topology::Field::getSubfieldInfo(const char* name) const {
601601
PYLITH_METHOD_BEGIN;
602+
assert(name);
602603

603604
subfields_type::const_iterator iter = _subfields.find(name);
604605
if (_subfields.end() == iter) {

0 commit comments

Comments
 (0)