Testing on the Toilet

Nov 13, 2008

Finding Data Races in C++ If you've got some multi-threaded code, you may have data races in it. Data races are hard to find and reproduce – usually they will not occur in testing but will fire once a month in production. For example, you ask each of your two interns to bring you a bottle of beer. This will usually result in your getting two bottles (perhaps empty), but in a rare situation that the interns collide near the fridge, you may get fewer bottles. 4 5 6 7 8 9 10 11 12 13 14 15

int bottles_of_beer = 0; void Intern1() { bottles_of_beer++; } // Intern1 forgot to use Mutex. void Intern2() { bottles_of_beer++; } // Intern2 copied from Intern1. int main() { // Folks, bring me one bottle of beer each, please. ClosureThread intern1(NewPermanentCallback(Intern1)), intern2(NewPermanentCallback(Intern2)); intern1.SetJoinable(true); intern2.SetJoinable(true); intern1.Start(); intern2.Start(); intern1.Join(); intern2.Join(); CHECK_EQ(2, bottles_of_beer) << "Who didn't bring me my beer!?"; }

Want to find data races in your code? Run your program under Helgrind! $ helgrind path/to/your/program Possible data race during read of size 4 at 0x5429C8 at 0x400523: Intern2() tott.cc:6 by 0x400913: _FunctionResultCallback_0_0::Run() ... by 0x4026BB: ClosureThread::Run() ... ... Location 0x5429C8 has never been protected by any lock Location 0x5429C8 is 0 bytes inside global var "bottles_of_beer" declared at tott.cc:4

Helgrind will also detect deadlocks for you. Helgrind is a tool based on Valgrind. Valgrind is a binary translation framework which has other useful tools such as a memory debugger and a cache simulator. Related TotT episodes will follow. No beer was wasted in the making of this TotT.

More information, discussion, and archives: http://googletesting.blogspot.com Copyright © 2007 Google, Inc. Licensed under a Creative Commons Attribution–ShareAlike 2.5 License (http://creativecommons.org/licenses/by-sa/2.5/).

Finding Data Races in C++ Code

If you've got some multi-threaded code, you may have data races in it. Data races ... Valgrind is a binary translation framework which has other useful tools such.

125KB Sizes 1 Downloads 264 Views

Recommend Documents

C++ Code
Dec 11, 2008 - It's easy to write the test using a mock tax server, which implements this interface: class TaxServer {. // Returns the tax rate of a location (by postal code) or -1 on error. ... life is unfair? More information, discussion, and archi

Course Code : CS-62 Course Title : 'C' Programming & Data ...
If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]. Course Code : CS-62. Course Title : 'C' Programming ...

Dynamically Detecting and Tolerating IF-Condition Data Races - iacoma
Typically, the ICIV is caused by a data race, which we call IF-Condition Data Race (ICR). ..... E only contains the ++ or - - operator, and Cetus can prove that there is no aliasing. In this case ...... Illinois-Intel Parallelism Center (I2PC). Refer

Finding Multiple Coherent Biclusters in Microarray Data ... - IEEE Xplore
Finding Multiple Coherent Biclusters in Microarray. Data Using Variable String Length Multiobjective. Genetic Algorithm. Ujjwal Maulik, Senior Member, IEEE, ...

Races of Stone.pdf
Page 3 of 211. Races of Stone.pdf. Races of Stone.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Races of Stone.pdf. Page 1 of 211.

Data structures in C++.pdf
count( ) return 0 or 1. reserve( ) set the number of buckets. size(). empty(). Nota: hash_table is a very efficient data structure but elements can not be ordered. - -.

Dynamically Detecting and Tolerating IF-Condition Data Races - iacoma
[email protected] [email protected] dahn2,[email protected] .... ICR bugs in the Cherokee web server and the Pbzip2 application;. SW-IF finds 3 of them.

Races
Aug 1, 2009 - MNR 3up STK/HCP 85000 - 125000 Dirt 6f. 7.3. 50%. 50%. +0.55. 4. $9.80. 50%. 50%. 0%. Track Bias Stats. * MEET Totals *. * WEEK Totals *. DIRT 6.0f. DIRT 6.0f. Speed Bias: 71%. Speed Bias: 60%. WnrAvgBL. WnrAvgBL. # Races: 327. # Races:

Races of Stone.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu.

Snail Races PDF.pdf
... was a problem loading this page. Snail Races PDF.pdf. Snail Races PDF.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Snail Races PDF.pdf.

Collaboration vs Disclosure in Dynamic R&D Races
Oct 27, 2011 - ference on The Economics of Intellectual Property, Software and the Internet, .... Hence, even if both firms are initially symmetric, their level of ..... To summarize, there is a clear connection between the uncertainty about.

Data-Driven Traps! Code
Sep 4, 2008 - This keeps the test code short and makes it easy to add new tests but makes it hard to identify a failing test assertion (and to get the debugger to stop in the right place). As your code grows the test data tends to grow faster than li

Finding Software License Violations Through Binary Code ... - NixOS
May 21, 2011 - 1The gpl-violations.org Project & Tjaldur Software Governance Solutions ..... Apply this to the Apple App Store / Android Marketplace.

Races of the Wild.pdf
C R E D I T S. Visit our website at www.wizards.com/dnd. D E S I G N. SKIP WILLIAMS ... Page 3 of 206. Main menu. Displaying Races of the Wild.pdf. Page 1 of ...

neet-code-c-answer-key.pdf
May 14, 2017 - 36. (3). 37. (4). 38. (4). 39. (1). 40. (1). 41. (2). 42. (1). 43. (4). 44. (4). 45. (3) ... BOOKLET CODE - C ... Displaying neet-code-c-answer-key.pdf.

neet-code-c-question-paper.pdf
Which of the following is made up of dead cells ? (1) Phloem. (2) Xylemparenchyma. (3) Collenchyma. (4) Phellem ... (b) They are somatic cells. (c) They do not metabolize. (d) Alltheirinternal space is availableforo)^gen ... i ii -k^ i i II. IP. fl.

c. Dutch Code Civil Procedure.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. c. Dutch Code Civil Procedure.pdf. c. Dutch Code Civil Procedure.pdf. Open. Extract. Open with. Sign In. Mai

Finding Hope Finding Hope
May 31, 2015 - At Home Study Guide. For the week of May 31, 2015. Psalm 23:4. Quick Review: The suspense of Psalm 23:4 provides a beautiful place for David to affirm His complete trust and dependence on his heavenly Father. The valleys and shadows pa

Statically determination of Races in Verilog Designs
Race conditions create such glitches in a logic circuit and can cause it to perform in an undesired manner. So, care should be taken while designing a logic circuit and races should be avoided as much as possible. Races are divided in to two categori

Genetic divergence in land races of rice
The maximum inter cluster distance was recorded between cluster IV and cluster V. The genotypes in these clusters. Vattan and Vellai Chitraikar (cluster IV) and ...

Collaboration vs Disclosure in Dynamic R&D Races
Oct 27, 2011 - ference on The Economics of Intellectual Property, Software and the Internet, ... and Fershtman and Markovich (2010) developed models of ..... vated in-house during the first period, and each firm i maximizes the following.