[erlang-questions] ets gives badarg after recompile

Andrew Arrow <>
Tue Nov 27 05:38:48 CET 2007


Well I tried to modify your example program to show what I'm seeing
but I can't reproduce the problem in a small example program.  I'm
doing something just like this:

-module(t).
-export([t/0]).

t()->
    process_flag(trap_exit, true),
    myname = ets:new(myname, [set, named_table]),
    true = ets:insert( myname, {a,1}),
    [{a,1}] = ets:lookup( myname, a ),
    Pid = self(),
    spawn_link(fun() -> another_func(Pid) end),
    receive
        {data} ->
            io:format("got it")
    end,
    true = ets:delete( myname ).

another_func(Pid) ->
    ets:lookup(myname, a),
    Pid ! {data}.

And for some reason I'll get a

Error in process <0.81.0> with exit value:
{badarg,[{ets,lookup,[myname,a]},{t,another_func,0}]}

after the 2nd compile.  It must mean that another_func is being run
AFTER the ets:delete( myname) already ran, but I don't see why this
could happen.




---------
Date: Mon, 26 Nov 2007 08:00:15 +0100
From: Bengt Kleberg <>
Subject: Re: [erlang-questions] ets gives badarg after recompile
To: 
Message-ID: <>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

greetings,

could you be a little more precise when describing the problem? given
this file:
-module(t).

-export([t/0]).

t()->
       myname = ets:new(myname, [set, named_table]),
       true = ets:insert( myname, {a,1}),
       [{a,1}] = ets:lookup( myname, a ),
       true = ets:delete( myname ).


i can do:
7> c(t).

{ok,t}
8> t:t().

true
9> t:t().

true
10> c(t).

{ok,t}
11> t:t().

true
12>



More information about the erlang-questions mailing list