IP Library Granted Patent US 8,813,038
Granted Patent B2
US 8,813,038 · App. 13/023,547 · Granted Aug 19, 2014

Data race detection

Inventors: John Erickson (Redmond, WA); Madan Musuvathi (Redmond, WA)
Assignee: Microsoft Corporation
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,813,038
App. No.
13/023,547
Granted
Aug 19, 2014
Kind
B2
Abstract

The claimed subject matter provides a method for detecting a data race. The method includes inserting a plurality of breakpoints into a corresponding plurality of program locations. Each of the program locations accesses a plurality of memory locations. Each of the program locations is selected randomly. The method also includes detecting one or more data races for the memory locations in response to one or more of the breakpoints firing. Additionally, the method includes generating a report describing the one or more data races.

Claims (65)

1. A processor-implemented method for detecting a data race, comprising:

inserting a plurality of breakpoints into a corresponding plurality of randomly selected program locations of a kernel mode program, wherein the program locations comprise instructions that access a plurality of memory locations;

pausing a thread at one of the breakpoints;

detecting one or more data races for the memory locations in response to one or more of the breakpoints firing by detecting a data race for a memory location accessed by instructions at one of the breakpoints, wherein the data race for the memory location is detected by trapping on a memory access to the memory location corresponding to the one of the breakpoints;

detecting a data race by using a repeated read comprising reading the memory location before and after the pause to determine if another thread modified the memory location, the repeated read detection carried out simultaneously with a detection of the data race with the second thread using the breakpoint; and

generating a report describing the one or more data races.

2. The processor-implemented method recited in claim 1 , wherein the data race is indirectly detected by repeated read of a same value at the memory location.

3. The processor-implemented method recited in claim 2 , wherein the repeated read comprises:

reading the memory location corresponding to the one of the breakpoints before pausing the thread;

reading the memory location corresponding to the one of the breakpoints after pausing the thread; and

determining that a value of the memory location after the pause is different than a value of the memory location before the pause.

4. The processor-implemented method recited in claim 1 , wherein the memory access by the thread is a write, and a type of trapping on the memory access is for a read or write to the memory location corresponding to the one of the breakpoints.

5. The processor-implemented method recited in claim 1 , wherein the memory access by the thread is a read, and a type of trapping on the memory access is for a write to the memory location corresponding to the one of the breakpoints.

6. The processor-implemented method recited in claim 1 , wherein the thread is executed in kernel mode.

7. The processor-implemented method recited in claim 6 , wherein pausing the thread comprises delaying the thread a predetermined amount of time, wherein an interrupt request level of the thread is at a DISPATCH level or lower.

8. The processor-implemented method recited in claim 1 , wherein inserting the plurality of breakpoints comprises:

generating a sampling set comprising the plurality of program locations, wherein the plurality of program locations comprise a corresponding plurality of instructions that access memory;

removing from the sampling set, one or more program locations comprising a thread-local instruction;

removing from the sampling set, one or more program locations comprising a synchronization instruction;

selecting from the sampling set, one or more of the program locations randomly, and uniformly; and

generating one or more corresponding breakpoints at the one or more selected program locations.

9. The processor-implemented method recited in claim 8 , comprising:

selecting from the sampling set, one of the program locations randomly, and uniformly; and

generating a breakpoint at the selected one of the program locations.

10. A system for detecting data races, comprising:

a processing unit; and

a system memory, wherein the system memory comprises code configured to direct the processing unit to:

pause a first thread of user mode execution;

detect a data race with a second thread for a memory location, wherein the data race with the second thread is detected by trapping a memory access by the second thread to the memory location using a breakpoint, and wherein the second thread comprises kernel mode execution; and

detect a data race by using a repeated read, simultaneously with a detection of the data race with the second thread using the breakpoint.

11. The system recited in claim 10 , wherein the code is configured to direct the processing unit to:

insert a plurality of breakpoints into a corresponding plurality of program locations, wherein each of the program locations comprise an instruction accessing a corresponding plurality of memory locations, and wherein each of the program locations is selected randomly, and wherein in response to a firing of one of the breakpoints, the processing unit performs:

the pause of the first thread;

the detection of the data race with the second thread; and

the detection of the data race using the repeated read; and

generate a report describing one or more data races comprising:

the data race with the second thread; and

the data race inferred using the repeated read.

12. The system recited in claim 11 , wherein the code configured to direct the processing unit to insert the plurality of breakpoints comprises code configured to direct the processing unit to:

generate a sampling set comprising the plurality of program locations, wherein the plurality of program locations comprise a corresponding plurality of instructions that access memory;

remove from the sampling set, one or more program locations comprising a thread-local instruction;

remove from the sampling set, one or more program locations comprising a synchronization instruction;

select from the sampling set, one or more of the program locations randomly, and uniformly; and

generate one or more corresponding breakpoints at the one or more selected program locations.

13. The system recited in claim 10 , wherein a type of the trapping is based on a memory access by the first thread.

14. The system recited in claim 13 , wherein the memory access by the thread is a write, and the type of the trapping is for a read or write to the memory location corresponding to the one of the breakpoints.

15. The system recited in claim 13 , wherein the memory access by the thread is a read, and the type of the trapping is for a write to the memory location corresponding to the one of the breakpoints.

16. The system recited in claim 10 , wherein the repeated read comprises code configured to direct the processing unit to:

read the memory location before pausing the thread;

reading the memory location after pausing the thread; and

determine that a value of the memory location after the pause is different than a value of the memory location before the pause.

17. The system recited in claim 10 , wherein the first thread is executed in kernel mode.

18. One or more computer-readable storage memories, comprising code configured to direct a processing unit to:

generate a sampling set of kernel code instructions that perform memory accesses;

remove thread-local instructions from the sampling set;

remove synchronization instructions from the sampling set;

insert a plurality of breakpoints into a corresponding plurality of program locations associated with the sampling set, wherein each of the program locations access a plurality of memory locations, and wherein each of the program locations is selected randomly;

detect one or more data races for the memory locations in response to one or more of the breakpoints firing, wherein the code configured to detect the one or more data races comprises code configured to direct the processing unit to:

pause a thread comprising one of the breakpoints;

detect a data race for a memory location corresponding to the one of the breakpoints, wherein the data race for the memory location is detected by trapping on a memory access to the memory location corresponding to the one of the breakpoints;

detect a data race by using a repeated read, simultaneously with a detection of the data race with the second thread using the breakpoint; and

generate a report describing the one or more data races.

19. The computer-readable storage memories recited in claim 18 , comprising code configured to direct a processing unit to:

prune one or more benign races from the one or more data races; and

generate a report describing the one or more data races.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 9, 2014
From: MICROSOFT CORPORATION
To: MICROSOFT TECHNOLOGY LICENSING, LLC
Reel/Frame 034544/0001 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 9, 2011
From: ERICKSON, JOHN; MUSUVATHI, MADAN
To: MICROSOFT CORPORATION
Reel/Frame 025770/0847 →
Continuity (1)
Related Publication 20120204062A1 · Aug 9, 2012