|
From: Alexander P. <gl...@go...> - 2011-12-16 12:35:57
|
On Fri, Dec 16, 2011 at 4:15 PM, Umesh Kalappa <ume...@gm...> wrote: > Hi All , > > Please attachment(threads.c) for the thread sample ,where sample is > multithread and below is the gcc switches used to compile the sample . > > # gcc -lpthread -o threads threads.c > > Question the sample has the issues like > 1)accessing like uninitialsed variable. > 2)write overflow. > . > why valgrind tools like helgrind/drd or memcheck unable to detect those > errors and here the o.p from them for the attached sample . As far as I can tell, there are no synchronization issues in this program, thus Helgrind and DRD aren't very helpful here (they don't implement the Memcheck functionality, otherwise the instrumentation should've become too heavy). The third and fourth threads contain out of bound accesses to stack and global variables. In the general case it is impossible to handle those using dynamic instrumentation. Sometimes such errors can be caught statically with Clang (http://clang.llvm.org), for more complex cases you can take a look at AddressSanitizer (http://code.google.com/p/address-sanitizer), which instruments the code at compile time and then detects the errors at runtime. The second thread contains a leak which is correctly detected by Memcheck. Regarding the first thread -- are you sure the variable wasn't optimized out? (the volatile keyword should help to make sure) HTH, Alex |