On Jan 27, 2010, at 3:28 PM, tom fogal wrote: > vicky lin <vicky....@gmail.com> writes: >> There was something strange happened when I used valgrind. I run >> my linux program written in c++ and it threw a "segment fault", but >> when I tried " valgrind --tool=memcheck -v ./mycode ", the program >> did't throw segment fault and continued to run and returned the >> experimental results. > [snip] >> Are the results got from running under valgrind environment valid? > > Well, your program is buggy, but valgrind is doing the best it can > under the circumstances. In that sense, the results are "valid". > > Your code almost definitely has some statement: > > *x = 42; [snip]
You could also get this sort of behavior if your program is multithreaded and has a race condition in it. Thread scheduling running under valgrind is different than when running natively on the OS: http://valgrind.org/docs/manual/manual-core.html#manual-core.pthreads > That said, if you've > got a reproducible case, you're much better off fixing that segfault > using gdb before running valgrind. Agreed. If it doesn't happen when running under the debugger (perhaps because of the threading mentioned above), you can usually figure out what happened using gdb on the core dump after the fact. -Dave ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users