Deconstructing Concurrency Heisenbugs Shaz Qadeer Research in - - PowerPoint PPT Presentation

deconstructing concurrency heisenbugs
SMART_READER_LITE
LIVE PREVIEW

Deconstructing Concurrency Heisenbugs Shaz Qadeer Research in - - PowerPoint PPT Presentation

Deconstructing Concurrency Heisenbugs Shaz Qadeer Research in Software Engineering Microsoft Research Concurrent Programming is HARD Concurrent Programming is HARD Concurrent executions are highly nondeterminisitic Rare thread interleavings


slide-1
SLIDE 1

Deconstructing Concurrency Heisenbugs

Shaz Qadeer Research in Software Engineering Microsoft Research

slide-2
SLIDE 2

Concurrent Programming is HARD Concurrent Programming is HARD

 Concurrent executions are highly nondeterminisitic  Rare thread interleavings result in Heisenbugs

 Difficult to find, reproduce, and debug

 Observing the bug can “fix” it

 Adding a print statement can change the scheduling behavior

 A huge productivity problem

 Developers and testers can spend weeks chasing a single

Heisenbug

slide-3
SLIDE 3

CHESS in a nutshell CHESS in a nutshell

 CHESS is a user‐mode scheduler  Controls all scheduling nondeterminism

 Replace the OS scheduler

 Guarantees:

 Every program run takes a different thread interleaving  Reproduce the interleaving for every run

slide-4
SLIDE 4

CHESS architecture CHESS architecture

Unmanaged Unmanaged Program Windows

CHESS

Win32 Wrappers

Exploration Engine CHESS Scheduler

Managed

  • Every run takes a different interleaving

g Program CLR

  • Every run takes a different interleaving
  • Reproduce the interleaving for every run

.NET Wrappers

slide-5
SLIDE 5

Errors that CHESS can find Errors that CHESS can find

 Assertions in the code  Any dynamic monitor that you run

 Memory leaks, double‐free detector, …

 Deadlocks

 Program enters a state where no thread is enabled

 Livelocks  Livelocks

 Program runs for a long time without making progress

 Dataraces

Dataraces

 Memory model races

slide-6
SLIDE 6

State space explosion State space explosion

x = 1; … x = 1; …

 Number of executions

= O( nnk )

… … … … … … … …

k steps each

 Exponential in both n and k

 Typically: n < 10 k > 100

x = k; x = k;

 Limits scalability to large

programs

n threads

programs

Goal: Scale CHESS to large programs (large k) Goal: Scale CHESS to large programs (large k)

slide-7
SLIDE 7

Preemption bounding Preemption bounding

 By default, CHESS is a non‐preemptive starvation‐free

scheduler scheduler

 Execute large chunks of code atomically

 Systematically insert a small number preemptions

Systematically insert a small number preemptions

 Preemptions are context switches forced by the scheduler

 e.g. Time‐slice expiration

 Non preemptions – a thread voluntarily yields  Non‐preemptions – a thread voluntarily yields

 e.g. Blocking on an unavailable lock, thread end

 Most errors are caused by few (≤ 2) preemptions  Most errors are caused by few (≤ 2) preemptions

slide-8
SLIDE 8

Polynomial state space Polynomial state space

 Terminating program with fixed inputs and deterministic threads

 n threads k steps each c preemptions  n threads, k steps each, c preemptions

 Number of executions <= nkCc . (n+c)!

= O( (n2k)c. n! )

Exponential in n and c, but not in k

slide-9
SLIDE 9

Progress report Progress report

 CHESS used by Microsoft product groups

SS used by c oso p oduc g oups

 Parallel Computing Platform (PCP)  SQL  Windows CE  Midori

 External release via DevLabs

 http://msdn microsoft com/devlabs/

http://msdn.microsoft.com/devlabs/

 Academic release

 http://research.microsoft.com/en‐us/projects/chess/

slide-10
SLIDE 10

Goal: Enable principled concurrent i (I) programming (I)

 Uncontrollable nondeterminism is the fundamental

problem T i

 Two options

 Deterministic semantics  Runtime hooks to expose and control nondeterminism  Runtime hooks to expose and control nondeterminism

 Remember that sequential programming works

q p g g primarily because the programmer can control and examine the computation

slide-11
SLIDE 11

Goal: Enable principled concurrent i (II) programming (II)

 Compositional methods for reasoning

 Formal or informal

 For sequential programs, we have

 Stack abstraction (pre and post conditions)  Data abstraction (invariants)  Data abstraction (invariants)

 What are the appropriate abstractions for concurrent

What are the appropriate abstractions for concurrent programs?