4,391 Posts served
10,712 Conversations started
- Academic

- Android

- Art, Music, & Animation

- Embedded Computing

- Events

- Game Development

- Graphics & Media

- Intel SW Partner Program

- Intel® AppUp Developer Program

- Manageability & Security

- Mobility

- Open Source

- Parallel Programming

- Performance and Optimization

- Power Efficiency

- Site News & Announcements

- Software Tools

- Association for Computing Machinery TechNews (ACM)
- Go Parallel! (Dr. Dobbs)
- HPCwire (Tabor Communications, Inc.)
- insideHPC (John West)
- Joe Duffy's Weblog (Microsoft)
- Microsoft Parallel Programming Development Center (Microsoft Germany)
- MultiCoreInfo.com
- scalability.org (Scalable Informatics)
- Software Dev Blog (Intel Germany)
- Soft Talk Blog (Intel United Kingdom)
- The Moth (Microsoft)
I just discovered Valgrind, it's about time.
By Ylian Saint-hilaire (Intel) (246 posts) on March 9, 2010 at 12:37 pm
Most of my coding career at Intel was been spend using C#, but with the mesh project, we needed to build the background peer-to-peer agent as small and as portable as possible and coding it in C made sense. Well, anything you code in raw C code, there are plenty of opportunities for problems. I have noticed that the mesh agent was not always stable and twice in the last month I saw it cause a segmentation fault. On Windows, the mesh agent runs as a service and the service manager is setup so it can restart the agent if anything goes wrong, but that only mask the problem.
Last week, I started looking at Valgrind more aggressively. Valgrind is an open source code checking tool. You just compile the code leaving in all of the debugging symbols and run "valgrind x" when x is your executable. In my case I run:
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes x
Where the last x is the executable. It runs the code with additional instrumentation and prints out problems as they happen. For example: If you start using a pointer that is not valid at the given time, or try jumping on an un-initialized value, etc. A quick look at the error logs revealed that I had indeed some problems. Two small ones and a really big one that likely caused my segmentation fault. An hour later and my code was running without causing valgrind to show any errors. So far, the code is running flawlessly. I am still running the mesh agent in Valgrind on my Linux machine in case something happens. My guess is, I am going to take the habit of always using Valgrind on some of my machines when running the mesh agent.
All in all, after running Visual Studio Static Code Analysts, Klocworks and Valgrind, I am feeling pretty happy about this code. I would not have gotten it this stable without all of these tools.
Ylian
opentools.homeip.net
Categories: Open Source
Tags: debug, leaks, segfault, valgrind
For more complete information about compiler optimizations, see our Optimization Notice.
Comments (1)
Trackbacks (1)
- Two For One! | Software Development with Linux
March 10, 2010 7:19 AM PST


Roman Dementiev (Intel)
2,205