Category Archives: Static Code Analysis

Valgrind – dynamic code analysis tool – part IV – DRD

Valgrind – DRD – while Helgrind is the major tool for concurrency issue detection, some options of DRD are also helpful on debugging concurrency issue, especially –exclusive-threshold, used to report mutex locked for long, and –shared-threshold, used to report shared … Continue reading

Posted in Static Code Analysis | Tagged , , , , , | Leave a comment

Valgrind – dynamic code analysis tool – part III – Helgrind

Valgrind – Helgrind – concurrency issue detection. # Helgrind http://valgrind.org/docs/manual/hg-manual.html –tool=helgrind [root@localhost valgrindTest]# cat simpleDataRace.c /* Code from Valgrind Manual */ #include <pthread.h> int var = 0; void* child_fn ( void* arg ) { var++; /* Unprotected relative to parent … Continue reading

Posted in Static Code Analysis | Tagged , , | 1 Comment

Valgrind – dynamic code analysis tool – part II – fd leak

Valgrind – File descriptor (fd) leak detection trial # File descriptor (fd) leak detection –track-fds=yes [root@localhost valgrindTest]# cat fdLeakTry.c /* daveti’s stupid code for fd leak */ #include <stdio.h> int main( int argc, char *argv[]) { FILE *fdPtr = fopen(“daveti.log”, … Continue reading

Posted in Static Code Analysis | Tagged , , | Leave a comment

Valgrind – dynamic code analysis tool – part I – basic trial and hints

We are recently trying to find a tool providing the ability for concurrency issue detection. For this topic, generally, I believe in 3 steps: 1. CPR (capacity, performance, redundancy) testing, 2. Static code analysis, 3. Dynamic code analysis. CPR testing … Continue reading

Posted in Static Code Analysis | Tagged , , , | 1 Comment

A bad include in C – why static code analysis is needed for modern C/C++ projects

We have already had a long discussion and argument for ‘include’ mechanism in C/C++, no matter good or bad, and this is not my intention here. I am writing this post to show a confusing compiler error we have recently … Continue reading

Posted in Programming, Static Code Analysis, Stuff about Compiler | Tagged , , | Leave a comment

cccmt – Coverity code complexity metrics tool

cccmt is used to parse the METRICS.errors.xml generated by cov-analyze of Coverity to produce a Code Complexity Metrics (CCM) report of different functions. SAX is used to parse XML file instead of DOM as the XML file may be very … Continue reading

Posted in Dave's Tools, Programming, Static Code Analysis | Tagged , , , , , , | Leave a comment

uninit member in destructor – Coverity UNINIT and UNINIT_CTOR checkers

Recently we encountered a serious bug like the code below – destructor function delete one member ptr, which was never init’d. At first, we were assuming checker UNINIT could help figure it out as we do not see any difference … Continue reading

Posted in Programming, Static Code Analysis | Tagged , | Leave a comment