Cactus should produce no errors in Valgrind

Create issue
Issue #1419 new
Steven R. Brandt created an issue

Valgrind is a useful tool for identifying a large number of coding problems. Currently, running Cactus under valgrind produces a large number of spurious errors due to the implementation of the string library. Attempts to use the valgrind suppression mechanism to eliminate them have proven difficult.

However, these errors all go away if we simply replace all calls to strdup() with calls to util_Strdup(), a function which is already part of Cactus. Making this replacement shouldn't have any negative impacts, and it would make valgrind more usable.


Comments (5)

  1. Erik Schnetter
    • removed comment

    util_Strdup is a old function, from times when strdup was not available everywhere. I would deprecate util_Strdup, and replace calls to this function by calls to strdup. This reduces code complexity and probably improves code speed as well.

    As to valgrind: Did you report this problem to the valgrind developers? The usual remedies would be (a) upgrade valgrind, or (b) upgrade libc.

    Instead of replacing all calls to strdup, you can define your own strdup function somewhere in the flesh, and then link statically to ensure this is the only definition available. This would be simpler than modifying all code, and would also ensure that calls within libraries (e.g. HDF5) are also replaced. Of course, this would be for debugging only, and would not be enabled for production runs.

  2. Frank Löffler
    • removed comment

    I remember using valgrind on a recent checkout of the ET and I didn't see these messages. Could this be related to a particular implementation of strdup?

  3. Steven R. Brandt reporter
    • removed comment

    Very likely it is platform dependent, but I've seen them on more than one platform.

  4. Frank Löffler
    • removed comment

    Is there a cluster where you can reproduce this that a lot of developers have access to? Otherwise it's a bit hard to reproduce.

  5. Log in to comment