Bug 478305
Summary: | libevent borked, upstream's event-test.c doesn't run correctly | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Evan Klitzke <evan> | ||||
Component: | libevent | Assignee: | Steve Dickson <steved> | ||||
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
Severity: | high | Docs Contact: | |||||
Priority: | low | ||||||
Version: | 10 | CC: | steved | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2008-12-31 18:53:22 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Evan Klitzke
2008-12-27 18:08:11 UTC
FWIW, I downloaded and compiled the 1.4.9 tarball (the latest stable release). When linking against that, event-test exhibits the correct behavior. Now I'm not so sure the problem is with libevent. When I built the new libevent yesterday things were working for a while, and now they're not again. The event-test.c program exhibits the same incorrect behavior as when linked to FC10's libevent as it does when linked against the 1.4.9 libevent that I built myself (i.e. it exits immediately). I'm going to poke around with libevent and see if I can come up with a better test case exhibiting the problem, but I don't have a lot of ideas... Created attachment 327916 [details]
shows what event_set is doing
OK, so I looked at this as much as I know how to, and here's what I've been able to find.
When I strace the programs I built with libevent (memcached and the event-test.c file) I found that after calling libevent's event_add, there was no call to epoll_ctl. This is consistent with the brokenness I see in memcached. I'm not able to connect to memcached because it's looping with epoll_wait on an epoll fd that isn't monitoring anything with it. I think it's also consistent with event-test.c exiting instead of blocking, because I guess that the epoll_add isn't really adding the fd to be monitored, so the libevent event loop has nothing to do. This makes event_dispatch return immediately.
So event_add isn't really adding the fd to be monitored. The question is, why is that? I think maybe I'm crazy or something but it looks like after returning from event_set the event struct that is passed in isn't initialized correctly? I'm kind of confused about this myself. If you run the attached C file (i.e. gcc -g -o evtest -levent evtest.c) I would expect it to print ev->ev_flags = 0x80 and ev->ev_events = 0x1 at the end, but it doesn't. This is curious to me because if I am understanding everything correctly, it looks like ev->ev_events and ev->ev_flags are correct inside of the event_set program when I run everything through gdb. IOW I might be misunderstanding things, but to me it looks like inside of event_set the struct members are correct, and then when it returns they got corrupted somehow.
Also, if you make ev not a local non-pointer allocated on the stack, and instead pass &ev to event_set you get a different result. But I'm not really a C programmer, I could be totally confused about the event_set part of the problem.
Here's what I'm seeing:
evtest.c, attached version:
EV_READ = 0x1
EV_RITE = 0x2
EV_SIGNAL = 0x400
EVLIST_INSERTED = 0x2
EVLIST_ACTIVE = 0x8
EVLIST_INIT = 0x80
ev->ev_flags = 0x0
ev->ev_events = 0x0
evtest.c, struct event ev declared local/on the stack:
EV_READ = 0x1
EV_RITE = 0x2
EV_SIGNAL = 0x400
EVLIST_INSERTED = 0x2
EVLIST_ACTIVE = 0x8
EVLIST_INIT = 0x80
ev->ev_flags = 0x7fff
ev->ev_events = 0x0
I think at this point it would be helpful if someone with better C knowledge took a look at this.
err I think this one was just PEBCAK |