Skip to content

Commit

Permalink
Merge pull request #794 from baagaard-usgs/feature-sanitize-configure…
Browse files Browse the repository at this point in the history
…-option

Add ability to build library with -fsanitize=address to help detect memory errors
  • Loading branch information
baagaard-usgs authored Nov 19, 2024
2 parents 218ecb1 + 2b15aae commit 3e921e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ AC_ARG_WITH([python-coverage],
[python_coverage="coverage2"])
AC_SUBST(python_coverage)

dnl sanitizer
AC_ARG_ENABLE([sanitizer],
[AC_HELP_STRING([--enable-sanitizer],
[enable compiling C++ code with -fsanitizer @<:@default=no@:>@])],
[if test "$enableval" != no; then enable_sanitizer=yes; else enable_sanitizer=no; fi;
if test "$enableval" = yes; then sanitizer=address; else sanitizer=$enableval; fi],
[enable_sanitizer=no])
if test "$enable_sanitizer" = "yes"; then
SANITIZER_CXXFLAGS="-fsanitize=$sanitizer"; export SANITIZER_CXXFLAGS
fi
AC_SUBST(SANITIZER_CXXFLAGS)

dnl CUBIT I/O w/netcdf
AC_ARG_ENABLE([cubit],
[AC_HELP_STRING([--enable-cubit],
Expand Down
2 changes: 1 addition & 1 deletion libsrc/pylith/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ libpylith_la_SOURCES = \
utils/TestArray.cc



libpylith_la_CXXFLAGS = $(SANITIZER_CXXFLAGS)
libpylith_la_LDFLAGS = $(AM_LDFLAGS) $(PYTHON_LDFLAGS) $(PYTHON_LA_LDFLAGS)
libpylith_la_LIBADD = \
-lspatialdata \
Expand Down
3 changes: 2 additions & 1 deletion libsrc/pylith/topology/Field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ pylith::topology::Field::getSubfieldNames(void) const {
names[sinfo.index] = s_iter->first;
} // for

PYLITH_METHOD_RETURN(pylith::string_vector(names));
PYLITH_METHOD_RETURN(names);
} // subfieldNames


Expand All @@ -599,6 +599,7 @@ pylith::topology::Field::getSubfieldNames(void) const {
const pylith::topology::Field::SubfieldInfo&
pylith::topology::Field::getSubfieldInfo(const char* name) const {
PYLITH_METHOD_BEGIN;
assert(name);

subfields_type::const_iterator iter = _subfields.find(name);
if (_subfields.end() == iter) {
Expand Down

0 comments on commit 3e921e2

Please sign in to comment.