Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using."— Presentation transcript:

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

2 Concurrency

3 Interprocess communication Synchronized shared structures Synchronous message passing on typed channels Asynchronous message passing

4 Erlang Strict, dynamically typed, functional Concurrency model: User-level processes Asynchronous message passing

5 Agenda

6

7

8 Postman Erlang VM

9 House Process

10 Address Process identifier

11 Mailbox Process mailbox

12 Mail Any valid Erlang term

13 Building a house Pid = spawn(Fun)

14 Sending mail Pid ! Msg

15 Receiving mail receive p 1 -> e 1 ; … p n -> e n end receive p 1 -> e 1 ; … p n -> e n end

16 Receiving mail receive p 1 -> e 1 ; … p n -> e n end receive p 1 -> e 1 ; … p n -> e n end msg 1 msg 2 msg 3

17 Receive with no messages Possible deadlock

18 Receive of the wrong kind Mailbox overflow

19 Receive with unneeded patterns Unreachable code or serious functionality issue

20 Send nowhere received Mailbox overflow

21 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. -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.

22 DIscrepancy AnaLYZer for ERlang Static analysis tool for finding discrepancies Type errors Exception-raising code Unsatisfiable conditions Redundancies Race conditions Why Dialyzer?

23 The analysis: pros Sound for defect detection

24 The analysis: pros Automatic

25 The analysis: pros Fast and scalable

26 The analysis: cons Sound for defect detection

27 The analysis: a 3-step process

28

29

30 1. Information CFGs Escape analysis Inter-modular call graph Sharing/alias analysis Type information

31 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. -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

32 2. Communication graph blah

33 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. -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.

34 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. -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

35 3. Errors No messages are sent to the process receive receive blah

36 3. Errors receive {A, 42} when is_atom(A) -> ok; foo -> … end receive {A, 42} when is_atom(A) -> ok; foo -> … end The pattern will never match messages sent to the process Infimum: {gazonk, 42} 43

37 Optimizations Control-flow graph minimization Avoiding repeated traversals Avoiding redundant traversals

38 False alarm avoidance BIFs Sharing/alias analysis

39 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. -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.

40 Experimental evaluation

41 Performance

42 Concluding remarks

43 Future work

44

45


Download ppt "Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas Detection of Asynchronous Message Passing Errors Using."

Similar presentations


Ads by Google