View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004954CMakeCMakepublic2007-04-30 16:012008-09-09 14:05
ReporterSean McBride 
Assigned ToBill Hoffman 
PrioritylowSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0004954: Support GuardMalloc on Mac OS X (MemoryCheckCommand)
DescriptionGuardMalloc is similar to valgrind. It checks for memory-related bugs.

If I type the following:

ctest -T memcheck -V -N

It says:

   Site: banshee.local
   Build name: Darwin-c++
 Add coverage exclude regular expressions.
 Add coverage exclude: vtk.*TCLInit.cxx
 Add coverage exclude: vtk[^\.]+Tcl.cxx
Create new tag: 20070430-1953 - Experimental
Start processing tests
Memory check project /Users/sean/kitware/VTK-pristine-bin
Memory checker (MemoryCheckCommand) not set, or cannot find the specified program.
Errors while running CTest

My understanding is that this is because MallocDebug is not supported. The wiki seems to confirm this:
<http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Dynamic_Analysis> [^]

as it does not mention anything for Mac OS X.

Supporting GuardMalloc would be pretty easy I believe. Basically, you set an environment variable then launch your process. It runs about 100x times slower, but is more likely to crash if you have memory-related bugs. The important env var is:

DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib

See 'man libgmalloc' for more info.

I would very much like to be able to test VTK with GuardMalloc enabled.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0013256)
Bill Hoffman (manager)
2008-09-02 14:04

This is really not like valgrind at all. It causes your program to crash. There is no additional output that ctest would be able to parse and report on the dashboard. The man page suggests that you run the program in gdb to find out what is wrong. I suppose you could just run a regular dashboard with this library on, and if a test fails, you have a memory issue. However, I don't see how this would work with ctest.
(0013257)
Sean McBride (reporter)
2008-09-02 16:44

Your observations are correct, GuardMalloc will cause the executable to crash. I've never used Valgrind, so I'm not sure how they compare.

I would indeed be happy to simply 'run a regular dashboard with this library on' and check for crashing tests. Is this possible with CMake today? I've tried:

SET (CTEST_ENVIRONMENT
"DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib"
)

But this seems to cause all subsequent processes to run with guardmalloc on, even gcc itself, so compilation takes forever. We need a way to set that env var only for spawned test processes.

BTW, there is an Apple employee working on a Mac port of Valgrind, but it's been a long time coming...
(0013258)
Bill Hoffman (manager)
2008-09-02 17:30

OK, I get it now.... We only want to run with that environment when running the tests... You could do it now, with the functional style ctest scripts I think...

Something like this should work:

CTEST_START (Nightly)
CTEST_UPDATE (SOURCE "${CTEST_SOURCE_DIRECTORY}")
CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}")
CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}")
SET(ENV{CTEST_ENVIRONMENT} "DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib")
CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_SUBMIT ()
(0013259)
Sean McBride (reporter)
2008-09-02 17:58

hmmm, and now you've lost me. :( Where can I RTFM about 'functional style ctest scripts'?

I have a feeling that your suggestion above means changing the project's cmake/ctest files... let's say I want to do a nightly VTK dashboard using GuardMalloc, does that mean I have to change VTK itself? Or could I achieve this by changing this file:
http://www.cdash.org/CDash/viewNotes.php?buildid=162232 [^]
(0013264)
Bill Hoffman (manager)
2008-09-02 21:19

No, you just have to change that file.

Here is a sample one from CMake:

http://www.cdash.org/CDash/viewNotes.php?buildid=162125 [^]

Basically, instead of just declaring a bunch of variables and running ctest on it, you use ctest commands and have more control over when things are done. So you can set environment variables, and then run the test part via the ctest_test() command of ctest.

Here is documentation for the commands:

http://www.cmake.org/HTML/ctest-2.6.html#section_Commands [^]
(0013276)
Sean McBride (reporter)
2008-09-03 11:54

OK, thanks. I will investigate this and attempted to add a nightly CMake build that uses GuardMalloc.

 Issue History
Date Modified Username Field Change
2008-09-02 14:04 Bill Hoffman Note Added: 0013256
2008-09-02 16:44 Sean McBride Note Added: 0013257
2008-09-02 17:30 Bill Hoffman Note Added: 0013258
2008-09-02 17:58 Sean McBride Note Added: 0013259
2008-09-02 21:19 Bill Hoffman Note Added: 0013264
2008-09-03 11:54 Sean McBride Note Added: 0013276
2008-09-09 14:05 Bill Hoffman Status assigned => closed
2008-09-09 14:05 Bill Hoffman Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team