Erlang Mailing Lists

Author Message

<  Erlang patches mailing list  ~  fix livelock in erts_poll_info_kp()

Guest
Posted: Wed May 12, 2010 10:04 am Reply with quote
Guest
erts_poll_info_kp() [defined in erts/emulator/sys/common/erl_poll.c
via some name-mangling trickery] contains a code path that can end
up in an infinite loop, causing a livelock. There is a block of code
inside #if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE that is supposed to
iterate over a linked list of ErtsPollSetUpdateRequestsBlocks and
update two variables based on the sizes of these blocks. The bug is
that the loop forgets to advance the list pointer to the next element,
so if the loop is entered at all (the initial list pointer is non-NULL),
the thread falls into an infinite loop.

This patch, against R13B03 but applies fine to today's git, fixes the
bug by adding a statement to advance the list pointer in the loop.
All other loops over this list appear to be correct.

Thanks to Chetan Ahuja for the original report of a livelock problem
in erts_poll_info_kp().

--- otp_src_R13B03/erts/emulator/sys/common/erl_poll.c.~1~ 2009-03-12 13:16:29.000000000 +0100
+++ otp_src_R13B03/erts/emulator/sys/common/erl_poll.c 2010-05-03 23:41:32.000000000 +0200
@@ -2404,6 +2404,7 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPol
while (urqbp) {
size += sizeof(ErtsPollSetUpdateRequestsBlock);
pending_updates += urqbp->len;
+ urqbp = urqbp->next;
}
}
#endif

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Wed May 12, 2010 10:24 am Reply with quote
Guest
erts_poll_info_kp() [defined in erts/emulator/sys/common/erl_poll.c
via some name-mangling trickery] contains a code path that can end
up in an infinite loop, causing a livelock. There is a block of code
inside #if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE that is supposed to
iterate over a linked list of ErtsPollSetUpdateRequestsBlocks and
update two variables based on the sizes of these blocks. The bug is
that the loop forgets to advance the list pointer to the next element,
so if the loop is entered at all (the initial list pointer is non-NULL),
the thread falls into an infinite loop.

This patch, against R13B03 but applies fine to today's git, fixes the
bug by adding a statement to advance the list pointer in the loop.
All other loops over this list appear to be correct.

Thanks to Chetan Ahuja for the original report of a livelock problem
in erts_poll_info_kp().

--- otp_src_R13B03/erts/emulator/sys/common/erl_poll.c.~1~ 2009-03-12 13:16:29.000000000 +0100
+++ otp_src_R13B03/erts/emulator/sys/common/erl_poll.c 2010-05-03 23:41:32.000000000 +0200
@@ -2404,6 +2404,7 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPol
while (urqbp) {
size += sizeof(ErtsPollSetUpdateRequestsBlock);
pending_updates += urqbp->len;
+ urqbp = urqbp->next;
}
}
#endif

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Sat May 15, 2010 8:28 am Reply with quote
Guest
On Wed, May 12, 2010 at 12:03 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
> erts_poll_info_kp() [defined in erts/emulator/sys/common/erl_poll.c
> via some name-mangling trickery] contains a code path that can end
> up in an infinite loop, causing a livelock.  There is a block of code
> inside #if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE that is supposed to
> iterate over a linked list of ErtsPollSetUpdateRequestsBlocks and
> update two variables based on the sizes of these blocks.  The bug is
> that the loop forgets to advance the list pointer to the next element,
> so if the loop is entered at all (the initial list pointer is non-NULL),
> the thread falls into an infinite loop.
>
> This patch, against R13B03 but applies fine to today's git, fixes the
> bug by adding a statement to advance the list pointer in the loop.
> All other loops over this list appear to be correct.
>

Thanks! Included in 'pu'.

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Sat May 15, 2010 8:28 am Reply with quote
Guest
On Wed, May 12, 2010 at 12:03 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
> erts_poll_info_kp() [defined in erts/emulator/sys/common/erl_poll.c
> via some name-mangling trickery] contains a code path that can end
> up in an infinite loop, causing a livelock.  There is a block of code
> inside #if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE that is supposed to
> iterate over a linked list of ErtsPollSetUpdateRequestsBlocks and
> update two variables based on the sizes of these blocks.  The bug is
> that the loop forgets to advance the list pointer to the next element,
> so if the loop is entered at all (the initial list pointer is non-NULL),
> the thread falls into an infinite loop.
>
> This patch, against R13B03 but applies fine to today's git, fixes the
> bug by adding a statement to advance the list pointer in the loop.
> All other loops over this list appear to be correct.
>

Thanks! Included in 'pu'.

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum