fix livelock in erts_poll_info_kp()

Mikael Pettersson mikpe@REDACTED
Wed May 12 12:03:32 CEST 2010


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


More information about the erlang-patches mailing list