[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Unitialized Memory Read when pushing >64 events at once
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] Unitialized Memory Read when pushing >64 events at once
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Sun, 29 May 2011 21:25:49 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sun, 29 May 2011 21:25:57 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=tMvRtWxTK54/FZBmo86uXRZ1FiES+fYTpK9CfuUnYMM=; b=HM/U6IkTd5u2t9CoerXgm/q5vnv5nTdWvJ2B2/8yFZr4FuDetu6Th3bn7/DT9LoZAU sLG9NFYwclSWk68rZSnoYJRLU3SDdqRVSnMrCUEy6JOpYoYN6Yj1Uj1zjF0sY3yAK89I FOJuryRL25uCsKeLufb6bTYWaNqpqO0FFzbkQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=g1Kg3FO4FspC5Ij/yva6FEJt27gjPyko+As3n5Vmen24azPWSMziQTqUKavVC5Mj+3 b8Lq8vubKcbBetsokGEeGuxuk1wh6DM+SEHr03oxVdoLGkBd6TZjaGFCpLv5GCTmafDx dTU4WCcr1v4VDilqzlBJOHiy3wJkKEQtKy/A0=
- In-reply-to: <BANLkTiknvF-fSirdibMuUaRasudcedo_gw@xxxxxxxxxxxxxx>
- References: <BANLkTiknvF-fSirdibMuUaRasudcedo_gw@xxxxxxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Sun, May 29, 2011 at 8:27 PM, Scott Dorr <j.scott.dorr@xxxxxxxxx> wrote:
> Purify complains about Unitialized Memory Reads when I try to push more than
> 64 events onto the queue at the same time. This is in a 64bit application
> running on RHEL linux. I'm currently using libevent-2.0.10-stable.
> epoll_dispatch triggers a set of of 4 UMRs for each event past the 64th that
> I push onto the event base. The first three are 1 byte reads on the stack
> (which it says is 20 bytes below the frame pointer in the epoll_dispatch
> function), and the fourth is a 4 byte read which is 388 bytes into a
> malloc'd block of 768 bytes. That malloc'd block was a realloc() that was
> called by epoll_dispatch->event_mm_realloc_
> I don't have libevent instrumented, otherwise I'd provide more detail. Is
> this a known issue?
Yuck. If this is still present in 2.0.11-stable (and I don't know why
it wouldn't be) we should track it down. Is there more info you can
copy and paste? Stack info would help a lot here, if you can get it.
Failing that, I don't have purify, and I don't have your test code, so
trying to reproduce this on my own could be tricky. Does this also
happen with valgrind? And do you have a small sample program you can
share? Is this with the changelist feature, or no?
Looking at the final case you mention, the only thing in
epoll_dispatch that calls mm_realloc is the code near the end of the
function that grows the events array. But so far as I can tell, we
never use any part of that array that isn't set by our call to
epoll_wait. Is it possible that purify doesn't know that when
epoll_wait returns "res", it has set the first "res" elements of its
third element?
Below is a short program I tried to use to reproduce this, but
valgrind didn't tell me about any reads of uninitialized memory. Does
purify complain about the program below?
Some possibilities include:
* It's a false positive from purify for some reason.
* It's an uninitialized-read that purify can find but valgrind can not.
* I'm using valgrind wrong.
* My test program below does not produce the bug.
* Something else that I'm not thinking of right now.
========
#include <stdio.h>
#include <event2/event.h>
void nilcb(evutil_socket_t s, short what, void *arg)
{
}
int main(int c, char **v)
{
struct event_base *base;
int fd[128];
struct event *ev[128];
int i;
base = event_base_new();
for (i=0;i<128;++i) {
fd[i] = socket(AF_INET, SOCK_DGRAM, 0);
if (fd[i]<0) {
perror("socket");
return 1;
}
ev[i] = event_new(base, fd[i], EV_WRITE, nilcb, NULL);
event_add(ev[i], NULL);
}
for (i=0;i<10;++i)
event_base_loop(base, EVLOOP_ONCE);
for (i=0;i<128;++i) {
event_free(ev[i]);
}
event_base_free(base);
return 0;
}
======
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.