[erlang-questions] Possible bug after ets:insert exception

Gleb Peregud gleber.p@REDACTED
Tue Aug 19 16:09:05 CEST 2008


On Tue, Aug 19, 2008 at 3:33 PM, Colm Dougan <colm.dougan@REDACTED> wrote:
> Hi,
>
> I'm running 12B-3.  Below is a console session.  Everything worked as
> expected until "4>" where I unintentionally provided an atom in my
> insert and I get a bad arg.  Again that was expected.  What I didn't
> expect, however, was that from then on the ets table seemed to be in a
> bad state and couldn't be queried.  I realise this is an edge case.
> Is this a bug?
>
> Colm
>
> Eshell V5.6.3  (abort with ^G)
> 1> ets:new(testtable,[set,named_table,private]).
> testtable
> 2> ets:insert(testtable, [{foo, 10}]).
> true
> 3> ets:tab2list(testtable).
> [{foo,10}]
> 4> ets:insert(testtable, bar).
> ** exception error: bad argument
>     in function  ets:insert/2
>        called as ets:insert(testtable,bar)
> 5> ets:tab2list(testtable).
> ** exception error: bad argument
>     in function  ets:match_object/2
>        called as ets:match_object(testtable,'_')
>     in call from ets:tab2list/1
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>

Hello,

The reason is slightly different. Take a look:

Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [hipe]
[kernel-poll:false]

Eshell V5.6.2  (abort with ^G)
1>  ets:new(testtable,[set,named_table,private]).
testtable
2> ets:i().
 id              name              type  size   mem      owner
 ----------------------------------------------------------------------------
 11              code              set   256    10161    code_server
 ...
 inet_hosts      inet_hosts        set   0      279      inet_db
 testtable       testtable         set   0      279      <0.30.0>
ok
3> self().
<0.30.0>
4> true = false.
** exception error: no match of right hand side value false
5> self().
<0.35.0>
6> ets:i().
 id              name              type  size   mem      owner
 ----------------------------------------------------------------------------
 11              code              set   257    10265    code_server
 ...
 inet_hosts      inet_hosts        set   0      279      inet_db
ok
7>

When there is an exception in shell, shell process crashes (take a
look at result of self/0). Because of that 'testtable' disappears from
the system. In "man ets" you can read the following: "When the process
terminates, the table is automatically destroyed."

BR
-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong



More information about the erlang-questions mailing list