maria christakis national technical university of athens, greece joint work with kostis sagonas...

45
Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using Static Analysis

Upload: warren-arron-stanley

Post on 13-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Maria Christakis

National Technical University of Athens, GreeceJoint work with

Kostis Sagonas

Detection of Asynchronous Message Passing Errors Using Static Analysis

Page 2: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Concurrency

Page 3: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Interprocess communication

Synchronized shared structuresSynchronous message passing on typed channelsAsynchronous message passing

Page 4: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Erlang

Strict, dynamically typed, functional

Concurrency model:User-level processesAsynchronous message passing

Page 5: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Agenda

Page 6: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Agenda

Page 7: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Agenda

Page 8: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Postman

Erlang VM

Page 9: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

House

Process

Page 10: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Address

Process identifier

Page 11: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Mailbox

Process mailbox

Page 12: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Mail

Any valid Erlang term

Page 13: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Building a house

Pid = spawn(Fun)

Page 14: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Sending mail

Pid ! Msg

Page 15: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Receiving mail

receive p1 -> e1; … pn -> en

end

Page 16: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Receiving mail

receive p1 -> e1; … pn -> en

end

msg1

msg2

msg3

Page 17: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Receive with no messages

Possible deadlock

Page 18: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Receive of the wrong kind

Mailbox overflow

Page 19: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Receive with unneeded patterns

Unreachable code or serious functionality issue

Page 20: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Send nowhere received

Mailbox overflow

Page 21: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Message passing example

-export([hello_world/0]).

hello_world() -> Self = self(), Fun = fun() -> world(Self) end, Pid = spawn(Fun), register(world, Pid), world ! hello.

world(Parent) -> receive hello -> Parent ! hi end.

Page 22: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

DIscrepancy AnaLYZer for ERlang

Static analysis tool for finding discrepancies

Type errors

Exception-raising code

Unsatisfiable conditions

Redundancies

Race conditions

Why Dialyzer?

Page 23: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: pros

Sound for defect detection

Page 24: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: pros

Automatic

Page 25: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: pros

Fast and scalable

Page 26: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: cons

Sound for defect detection

Page 27: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: a 3-step process

Page 28: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: a 3-step process

Page 29: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

The analysis: a 3-step process

Page 30: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

1. InformationCFGs

Escape analysis

Inter-modular call graph

Sharing/alias analysis

Type information

Page 31: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

1. Information

-export([hello_world/0]).

hello_world() -> Self = self(), Fun = fun() -> world(Self) end, Pid = spawn(Fun), register(world, Pid), world ! hello.

world(Parent) -> receive hello -> Parent ! hi end.

Call graph

Page 32: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

2. Communication graph

blah

Page 33: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

2. Communication graph

-export([hello_world/0]).

hello_world() -> Self = self(), Fun = fun() -> world(Self) end, Pid = spawn(Fun), register(world, Pid), world ! hello.

world(Parent) -> receive hello -> Parent ! hi end.

hel l o_wor l d/ 0 Fun

hel l o

hi

Page 34: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

3. Errors

-export([hello_world/0]).

hello_world() -> Self = self(), Fun = fun() -> world(Self) end, Pid = spawn(Fun), register(world, Pid), world ! hello.

world(Parent) -> receive hello -> Parent ! hi end.

The message will never be received

Page 35: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

3. Errors

No messages are sent to the process

receivereceive blah

Page 36: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

3. Errors

receive {A, 42} when is_atom(A) -> ok; foo -> …end

The pattern will never match messages sent to the process

Infimum: {gazonk, 42}

43

Page 37: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Optimizations

Control-flow graph minimization

Avoiding repeated traversals

Avoiding redundant traversals

Page 38: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

False alarm avoidance

BIFsSharing/alias analysis

Page 39: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

False negatives

-export([hello_world/0]).

hello_world() -> Self = self(), Fun = fun() -> world(Self) end, Pid = spawn(Fun), register(world, Pid), world ! hello.

world(Parent) -> receive hello -> Parent ! hi, world(Parent) end.

Page 40: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Experimental evaluation

Page 41: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Performance

Page 42: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Concluding remarks

Page 43: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Future work

Page 44: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Future work

Page 45: Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using

Future work