Racetrack: Efficient Detection of Data Race Conditions Via Adaptive

Racetrack: Efficient Detection of Data Race Conditions Via Adaptive

RaceTrack: Efficient Detection of Data Race Conditions via Adaptive Tracking Yuan Yu Tom Rodeheffer Wei Chen Microsoft Research Microsoft Research Computer Science Division 1065 La Avenida Ave. 1065 La Avenida Ave. University of California Mountain View, CA 94043 Mountain View, CA 94043 Berkeley, CA 94720 [email protected] [email protected] [email protected] ABSTRACT that trigger a data race is timing sensitive, data races are Bugs due to data races in multithreaded programs often ex- difficult to reproduce, even when the program is executed hibit non-deterministic symptoms and are notoriously dif- repeatedly with the same inputs. Furthermore, since a data ficult to find. This paper describes RaceTrack, a dynamic race typically results in corrupted shared data structures race detection tool that tracks the actions of a program and rather than an immediate crash, programs may continue reports a warning whenever a suspicious pattern of activity to execute, leading to mysterious failures later in unrelated has been observed. RaceTrack uses a novel hybrid detection code. Automatically finding data races in a program thus is algorithm and employs an adaptive approach that automat- widely recognized as an important research problem. ically directs more effort to areas that are more suspicious, thus providing more accurate warnings for much less over- 1.1 Related Work head. A post-processing step correlates warnings and ranks Automated tools for race detection generally take either code segments based on how strongly they are implicated in a static or a dynamic approach. For static race detection, potential data races. We implemented RaceTrack inside the the most common approach is to employ compile-time anal- virtual machine of Microsoft’s Common Language Runtime ysis on the program source, reporting all potential races that (product version v1.1.4322) and monitored several major, could occur in any possible program execution [10, 14, 32]. real-world applications directly out-of-the-box, without any The primary drawback of this approach is excessive false modification. Adaptive tracking resulted in a slowdown ra- positives (reporting a potential data race when none exists), tio of about 3x on memory-intensive programs and typically since the compile-time analysis is often unable to determine much less than 2x on other programs, and a memory ratio the precise set of possible thread interleavings and thus must of typically less than 1.2x. Several serious data race bugs make a conservative estimate. Scaling is also difficult, since were revealed, some previously unknown. the entire program must be analyzed. Another approach Categories and Subject Descriptors: D.2.5 [Software is to augment the programming language’s type system to Engineering]: Testing and Debugging—diagnostics, moni- express common synchronization relationships, so that any tors well-typed program is guaranteed to be free of data races [2, General Terms: Reliability, Performance. 11]. This language-level approach eliminates data races alto- gether, but requires a substantial amount of code annotation Keywords: Race detection, virtual machine instrumenta- and also restricts the kinds of synchronization that can be tion. expressed. For dynamic race detection, the program is executed and 1. INTRODUCTION a history of its memory accesses and synchronization oper- A data race occurs in a multithreaded program when two ations is recorded and analyzed. Because the history is in threads access the same memory location without any inter- fact a feasible execution, dynamic detectors typically suffer a vening synchronization operations, and at least one of the lower false positive rate than static detectors. On the other accesses is a write. Data races almost always indicate a pro- hand, since not all possible execution paths are considered, gramming error and such errors are notoriously difficult to the dynamic technique is not sound and thus cannot certify find and debug, due to the non-deterministic nature of multi- a program to be free of data races. The dynamic technique threaded programming. Since the exact schedule of threads also imposes runtime overhead which must be kept within limits while still providing reasonably accurate race detec- tion. The post-mortem approach records events during pro- gram execution and analyzes them later [1], or records only Permission to make digital or hard copies of all or part of this work for critical events and then carefully replays the program [5, personal or classroom use is granted without fee provided that copies are 27]. This approach is unsuitable for long-running applica- not made or distributed for profit or commercial advantage and that copies tions that have extensive interactions with their environ- bear this notice and the full citation on the first page. To copy otherwise, to ment. The other approach is to record and analyze infor- republish, to post on servers or to redistribute to lists, requires prior specific mation as efficiently as possible on-the-fly. permission and/or a fee. SOSP’05, October 23–26, 2005, Brighton, United Kingdom. Existing analysis techniques used in dynamic race detec- Copyright 2005 ACM 1-59593-079-5/05/0010 ...$5.00. tors are lockset analysis and happens-before analysis.Lockset- 221 based detectors verify that the program execution conforms VB C++ C# JScript … to a locking discipline, a programming methodology that ensures the absence of data races. Eraser [28], for example, Common Language Specification enforces the locking discipline that every shared variable is protected by some lock. Basically, each shared variable is ASP.NET Windows Forms associated with a lockset that keeps track of all common locks held during accesses, and a warning is issued when the Data and XML Classes lockset becomes empty. Later lockset-based detectors [21, 25] refine Eraser’s lockset algorithm with more states and Base Class Library transitions to reduce the number of false positives. Common Language Runtime Happens-before detectors [1, 5, 6, 7, 18, 27, 30] are based on Lamport’s happens-before relation [15], which combines Windows COM+ Services program order and synchronization events to establish a partial temporal ordering on program statements. A data race occurs when there is no established temporal order- Figure 1: The .NET framework ing between two conflicting memory accesses—neither ac- cess “happens before” the other. Compared to the lockset method, happens-before detection is more general and can running time to within a factor of two of the original pro- be applied to programs using non-lock-based synchroniza- gram. The performance improvement, however, is achieved tion primitives such as fork/join or signal/wait. Happens- at the expense of detection accuracy, as the coarser detec- before also never reports a false positive in the absence of tion unit leads to many false alarms. More advanced tools a data race. However, it is less efficient to implement than provide a mechanism for focusing the analysis. Posniansky lockset analysis and is much more likely to suffer false neg- and Schuster provide a parameterized detection granularity: atives (failing to detect a potential race) because of its sen- the program is initially run using a generous detection gran- sitivity to the particular thread schedule. Many detectors ularity of say, 256 bytes, and if potential races are detected attempt to get the advantages of both lockset and happens- the program can be re-run using a smaller granularity to get before analysis by combining the techniques in some way [13, more accuracy [24]. O’Callahan and Choi provide a two-pass 22, 24, 33]; in fact, Dinning and Schonberg originated the solution: the program is initially run using lockset analysis idea of lockset-based race detection as an improvement to a to identify problematic fields (“simple mode”) and if any happens-before detector [8]. are detected the program is re-run using a combined lockset Dynamic race detectors also vary in the technique used and happens-before analysis for just those fields (“detailed to monitor program execution. In one approach, the pro- mode”) [22]. Choi et al. apply compile-time analysis tech- gram binary is modified to instrument each load and store niques, such as points-to and escape analysis, to determine instruction that accesses global memory [13, 23, 28]. While which accesses can never participate in data races and thus this approach is language independent and requires no pro- do not need to be monitored [4]. gram source, it also results in high overhead in both time and space. Using Eraser, for example, applications typically run10to30timesslowerandashadow word is required for 1.2 The RaceTrack Approach each word in global memory to store lockset information. In this paper, we present RaceTrack, a practical, on-the- When applied to modern programming languages, binary fly race detection tool for large multithreaded object-oriented instrumentation also suffers from an inability to utilize type programs on the Microsoft .NET platform. Figure 1 illus- information to generate more accurate reports and reduce trates the .NET framework. At the core of the framework execution overhead. Furthermore, hooks are needed into is the Common Language Runtime (CLR) [12], a language- the runtime’s memory allocator so that the shadow memory independent layer that provides a managed execution en- can correctly reflect the state of newly-allocated memory. vironment for applications. Applications written in vari- A modern runtime that uses a copying garbage collector ous languages are translated into the Common Intermediate presents even more problems. Language (IL) [9], a stack-based language with memory ac- Race detectors for modern object-oriented programming cess, arithmetic, and method call instructions and descrip- languages have therefore generally adopted a higher-level tive metadata containing type and version information. As approach [6, 21, 22, 24, 25]. These tools modify the source an application executes, the IL is converted into native ma- code, the compiler, intermediate bytecodes, or the virtual chine code by a just-in-time (JIT) compiler in the CLR.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us