valgrind stuff

Brandon Black blblack at gmail.com
Wed Apr 9 23:40:23 CEST 2008


Brandon Black wrote:

> Sorry maybe I wasn't clear.  Those error messages I pasted are a 
> completely separate issue from the realloc thing.  I tracked it down now 
> to the point that I can interpret the messages (and exactly when they 
> occur) as meaning: when poll_poll() is called, the 0th member of the 
> poll set, which is the read side of the pipe that's set up for signals 
> and such, has an "revents" member which is uninitialized memory, and 
> poll_poll() is making decisions based on reading that ununitialized 
> memory.  The reason I don't see any worse behavior is that even though 
> it's "uninitialized", being an early allocation it tends to be zero'd 
> out anyways by chance.
> 

Here's an interesting thread from another list regarding this exact same 
problem:

http://lists.freedesktop.org/archives/dbus/2006-September/005724.html

I'm still a little hazy on what the "right" answer is here, as I'm not a 
  poll() expert, but something like this may be the answer:

diff -u -r1.21 ev_poll.c
--- ev_poll.c	25 Dec 2007 07:05:45 -0000	1.21
+++ ev_poll.c	9 Apr 2008 21:38:51 -0000
@@ -101,6 +101,8 @@
        return;
      }

+  if(res == 0) return;
+
    for (i = 0; i < pollcnt; ++i)
      if (expect_false (polls [i].revents & POLLNVAL))
        fd_kill (EV_A_ polls [i].fd);






More information about the libev mailing list