dets fatal bug

klacke@REDACTED klacke@REDACTED
Tue Dec 23 01:10:15 CET 2003


I've started to distrust dets:





The following program:

-module(detsloop).
-compile(export_all).

start(Arg) ->
    case catch (run(Arg)) of
	{'EXIT', Rsn} ->
	    {ok, Out} = file:open("err", [append]),
	    io:format(Out, "~p~n",[Rsn]);
	_ ->
	    ok
    end.

run([I]) ->
    Int = list_to_integer(atom_to_list(I)),
    case dets:open_file(a, [{file, "foooo"}]) of
	{ok, Name} ->
	    dloop(Name, 1);
	Err ->
	    ok = file:delete("foooo"),
	    exit({Int, Err})
    end.

dloop(Name, I) ->
    dets:insert(Name, {I, akakaka,3.45, make_ref(), self(),"aaaaaaaaaaaaa",
		       33333333333333333333333333333333333}),
    dloop(Name, I+1).





Run from the following pretty brutal shell script:
(invoke shellscript with numeric arg)

#!/bin/sh

i=$1;
while [ $i -gt 0 ]; do
    echo $i
    i=`expr $i - 1`
    erl -detached -s detsloop start $i
    sleep 6
    killall -KILL beam
    sleep 1
done



Will produce an err log containing a number of

{8,{error,{not_a_dets_file,"foooo"}}}
.....

entries, Thus KILL ing erlang while writing a detsfile
corrupts the dets file beyond repair. Bad.



Here is some system info:


fs: reiserfs
linux 2.6.0
erl: R9C-0


I've had similar behaviour on less exotic linuxen as well.



/klacke  -- Sending a bugreport without a fix :-(





-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control          



More information about the erlang-questions mailing list