1 / 45

Detection of Asynchronous Message Passing Errors Using Static Analysis

Detection of Asynchronous Message Passing Errors Using Static Analysis. Maria Christakis National Technical University of Athens, Greece Joint work with Kostis Sagonas. Concurrency. Interprocess communication. Synchronized shared structures Synchronous message passing on typed channels

Download Presentation

Detection of Asynchronous Message Passing Errors Using Static Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  7. Agenda

  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 p1 -> e1; … pn -> en end

  16. Receiving mail msg1 receive p1 -> e1; … pn -> en end msg2 msg3

  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.

  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. The analysis: a 3-step process

  29. The analysis: a 3-step process

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

  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. The message will never be received

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

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

  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.

  40. Experimental evaluation

  41. Performance

  42. Concluding remarks

  43. Future work

  44. Future work

  45. Future work

More Related