Maria Christakis
National Technical University of Athens, GreeceJoint work with
Kostis Sagonas
Detection of Asynchronous Message Passing Errors Using Static Analysis
Interprocess communication
Synchronized shared structuresSynchronous message passing on typed channelsAsynchronous message passing
Erlang
Strict, dynamically typed, functional
Concurrency model:User-level processesAsynchronous message passing
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.
DIscrepancy AnaLYZer for ERlang
Static analysis tool for finding discrepancies
Type errors
Exception-raising code
Unsatisfiable conditions
Redundancies
Race conditions
Why Dialyzer?
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
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
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
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
Optimizations
Control-flow graph minimization
Avoiding repeated traversals
Avoiding redundant traversals
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.