[erlang-questions] [erlang-bugs] Bad object error in dets in R14B02

Joe Armstrong erlang@REDACTED
Thu May 19 23:08:49 CEST 2011


Brilliant - worth a slide in a lecture

Here is code (dets) that is 1) battle tested 2) impossible to
prove correct 3) highly tested 4) believed reliable
but nevertheless buggy and you find the bug even though it has not been
reported.

/Joe

On Mon, May 16, 2011 at 6:23 PM, John Hughes <john.hughes@REDACTED> wrote:

>  QuickCheck found another error in dets. The following test case shows how
> to provoke a bad object error by starting three concurrent match_object
> traversals, at the same time as data is inserted into the table.
>
> test() ->
>     dets:close(dets_table),
>     file:delete(dets_table),
>     {ok,dets_table} = dets:open_file(dets_table,[{type,bag}]),
>     ok = dets:insert(dets_table,[{0,0},{0,14},{1,0},{1,1},{39,0}]),
>     {[{0,14}],Cont} = dets:match_object(dets_table,{'$1',14},0),
>     ok = dets:insert(dets_table,{2,0}),
>     {[{0,0},{0,14}],_} = dets:match_object(dets_table,{0,'$2'},0),
>     ok = dets:insert(dets_table,[{2,1},{39,1}]),
>     {[{1,0}],_} = dets:match_object(dets_table,{'$1',0},0),
>     {error,{{bad_object,scan},"dets_table"}} = dets:match_object(Cont).
>
> This is 100% repeatable--and it seems to be a minimal example.
>
> John
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110519/4d423c25/attachment.htm>


More information about the erlang-questions mailing list