Make "make check" abort on memory leaks or errors

2014-07-10 Thread Steffen Dettmer
Hi,

I have s small C++ test project using autoconf, automake and CppUnit.
I like to check for memory errors, starting with memory leaks.
I started with "./configure CXXFLAGS=-fsanitize=address", which
detects some memory errors (e.g. use-after-delete), but no memory
leaks.

After searching the web for a while, I thougt to fall-back to valgrind
using "make check TESTS_ENVIRONMENT=valgrind". Althrough "valgrind
./mytestrunner" works (test program aborts because of memory leak),
"make check TESTS_ENVIRONMENT=valgrind" does not work, it errnously
returns status 0, no memory errors are reported. Maybe valgrind
checked the automatically generated automake "test-driver" script for
memory leaks?

Since I assume checking memory usage errors is a coomon requirement, I
think there could be a common solution, but I failed to find it. Could
anyone please advice how to check for memory leaks?

A pragma solution specific/limited to g++ (4.8) on Linux (e.g. Lubuntu
14.04) without libtool would be sufficient.

Regards,
Steffen



Re: Make "make check" abort on memory leaks or errors

2014-07-08 Thread Simon Newton
On Tue, Jul 8, 2014 at 8:04 AM, Steffen Dettmer
 wrote:
> Hi,
>
> I have s small C++ test project using autoconf, automake and CppUnit.
> I like to check for memory errors, starting with memory leaks.
> I started with "./configure CXXFLAGS=-fsanitize=address", which
> detects some memory errors (e.g. use-after-delete), but no memory
> leaks.
>
> After searching the web for a while, I thougt to fall-back to valgrind
> using "make check TESTS_ENVIRONMENT=valgrind". Althrough "valgrind
> ./mytestrunner" works (test program aborts because of memory leak),
> "make check TESTS_ENVIRONMENT=valgrind" does not work, it errnously
> returns status 0, no memory errors are reported. Maybe valgrind
> checked the automatically generated automake "test-driver" script for
> memory leaks?
>
> Since I assume checking memory usage errors is a coomon requirement, I
> think there could be a common solution, but I failed to find it. Could
> anyone please advice how to check for memory leaks?
>
> A pragma solution specific/limited to g++ (4.8) on Linux (e.g. Lubuntu
> 14.04) without libtool would be sufficient.

I use tcmalloc to detect leaks. Our ./configure has a
--enable-tc-malloc which sets -ltcmalloc and then you just need to add
HEAPCHECK=normal .

Simon

>
> Regards,
> Steffen
>



Re: Make "make check" abort on memory leaks or errors

2014-07-10 Thread Bob Friesenhahn
For GraphicsMagick I added a 'memcheck' target which performs 'make 
check' under valgrind.  This requires that subordinate test scripts 
will prefix test executable invokations with $MEMCHECK and that any 
necessary valgrind suppressions exist in order to allow the tests to 
succeed when there are no problems.  Normally Automake tests run to 
completion and report the tests which have failed rather than 
immediately 'aborting' the tests.  The valgrind reports can then be 
found in a test log file.


# memcheck: valgrind's memory access checker.
# The suppressions which come with valgrind are usually insufficient
# to handle certain pthread library aspects and gomp and so errors
# will be reported which are unrelated to GraphicsMagick.  When first
# starting with a new system (or after a major system update), it is
# good to execute the test suite like 'make memcheck
# VALGRIND_EXTRA_OPTS=--gen-suppressions=all' to create valgrind
# suppression entries in the test log.  Tell valgrind about the
# suppressions by creating a .valgrindrc file with content like:
#   --memcheck:suppressions=mysupp.supp
memcheck:
$(MAKE) MEMCHECK='valgrind --tool=memcheck --leak-check=full 
--read-var-info=yes \
--error-exitcode=2 --track-origins=yes --num-callers=12 \
--quiet $(VALGRIND_EXTRA_OPTS)' check

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/