aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2011-03-21 18:32:11 +0200
committerHenrik Nord <[email protected]>2011-05-04 15:06:17 +0200
commitafd9dd57e0460957bfe67df22b93857f25eb886c (patch)
tree5ba38777721db182cae731f83cd6ae8bad9277f5 /lib
parent5e76fd508af2799fbefe062fd8bb106ae316cf5d (diff)
downloadotp-afd9dd57e0460957bfe67df22b93857f25eb886c.tar.gz
otp-afd9dd57e0460957bfe67df22b93857f25eb886c.tar.bz2
otp-afd9dd57e0460957bfe67df22b93857f25eb886c.zip
Add race/ets_insert_public
Diffstat (limited to 'lib')
-rw-r--r--lib/dialyzer/test/race_SUITE_data/results/ets_insert_public2
-rw-r--r--lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl23
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/dialyzer/test/race_SUITE_data/results/ets_insert_public b/lib/dialyzer/test/race_SUITE_data/results/ets_insert_public
new file mode 100644
index 0000000000..d091ce3b50
--- /dev/null
+++ b/lib/dialyzer/test/race_SUITE_data/results/ets_insert_public
@@ -0,0 +1,2 @@
+
+ets_insert_public.erl:14: The call ets:insert(Foo::atom(),{'counter',number()}) might have an unintended effect due to a possible race condition caused by its combination with the ets:lookup(Foo::atom(),'counter') call in ets_insert_public.erl on line 12
diff --git a/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl b/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl
new file mode 100644
index 0000000000..4caa9fe8a0
--- /dev/null
+++ b/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl
@@ -0,0 +1,23 @@
+%% This tests the presence of possible races due to an ets:lookup/ets:insert
+%% combination. It takes into account any public ETS tables that might exist.
+
+-module(ets_insert_public).
+
+-export([main/1]).
+
+%% Main
+main(Foo) ->
+ make_table(Foo),
+ ets:insert(Foo, {counter, 0}),
+ [{_, N}] = ets:lookup(Foo, counter),
+ NewN = N + 1,
+ ets:insert(Foo, {counter, NewN}),
+ NewN.
+
+make_table(Foo) ->
+ init(Foo).
+
+init(Foo) ->
+ ets:new(Foo, [named_table, public]),
+ ets:insert(Foo, {counter, 0}),
+ {ok, feeling_good}.