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

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


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]).
    2> self() ! some_msg.
    3> erlang:process_info(self(), messages).
    4> erlang:process_info(self(), message_queue_len).
    5> C=qlc:cursor(ets:table(qlc_test)).
    6> erlang:process_info(self(), messages).
    7> erlang:process_info(self(), message_queue_len).
    8> qlc:delete_cursor(C).

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) ->
            %% ... snipped code ...
            _Ignored ->
                parent_fun(Pid, Parent)

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.

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