[erlang-questions] Bug in qlc when a cursor is created

christopher faulet christopher.faulet@REDACTED
Mon Mar 31 17:36:56 CEST 2008


Hi,

I think there is a bug in the qlc module. It seems that the creation of
a cursor is a little bit greedy with messages in current process queue:

    1> ets:new(qlc_test, [named_table, public]).
    qlc_test
    2> self() ! some_msg.
    some_msg
    3> erlang:process_info(self(), messages).
    {messages,[some_msg]}
    4> erlang:process_info(self(), message_queue_len).
    {message_queue_len,1}
    5> C=qlc:cursor(ets:table(qlc_test)).
    {qlc_cursor,{<0.38.0>,<0.32.0>}}
    6> erlang:process_info(self(), messages).
    {messages,[]}
    7> erlang:process_info(self(), message_queue_len).
    {message_queue_len,0}
    8> qlc:delete_cursor(C).
    ok

I made my tests on R12B-1 but it exists in previous versions. After some
investigation in the qlc module, I found a "catch all" clause in the
function parent_fun:

    parent_fun(Pid, Parent) ->
        receive
            %% ... snipped code ...
            _Ignored ->
                parent_fun(Pid, Parent)
        end.


IMHO, this clause must be removed otherwise we cannot "safely" create a
cursor. An other solution might be to spawn the creation and send back
the result. But it seems tedious (and undocumented).

Here is a patch for the release R12B-1.

Regards,
-- 
Christopher Faulet
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qlc.patch
Type: text/x-patch
Size: 502 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080331/35dcb8a4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080331/35dcb8a4/attachment-0001.bin>


More information about the erlang-questions mailing list