Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to build library with -fsanitize=address to help detect memory errors #794

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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