This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16524] New: eventfd_write() doesn't work when 2nd argument is zero
- From: "structurechart at yahoo dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 04 Feb 2014 09:59:13 +0000
- Subject: [Bug libc/16524] New: eventfd_write() doesn't work when 2nd argument is zero
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16524
Bug ID: 16524
Summary: eventfd_write() doesn't work when 2nd argument is zero
Product: glibc
Version: 2.12
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: structurechart at yahoo dot com
CC: drepper.fsp at gmail dot com
Hi,
I searched for eventfd_write in bugzilla here but I don't see any bug.
Hope that I don't file a bug that has been fixed.
The problem is that when eventfd() is called with 2nd argument=0, epoll_wait()
never returns, but when the argument is set to 1. epoll_wait() returns.
Here is how I reproduce:
./bug 0
It never returns.
./bug 1
It returns.
Here is the code:
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <assert.h>
#include <cstdlib>
#include <iostream>
int value = 0;
int efd = 0;
void* start(void* p) {
std::cout << __PRETTY_FUNCTION__ << ": going to sleep for 5 sec" <<
std::endl;
sleep(5);
std::cout << __PRETTY_FUNCTION__ << ": going to call eventfd_write() with
value=" << value << std::endl;
const int rc = eventfd_write(efd, value);
assert(0 == rc);
return NULL;
}
int main(int argc, char** argv) {
const int epFD = epoll_create1(0);
assert(-1 != epFD);
efd = eventfd(0, 0);
assert(-1 != efd);
struct epoll_event event;
event.data.fd = efd;
event.events = EPOLLIN;
epoll_ctl(epFD, EPOLL_CTL_ADD, efd, &event);
value = strtoul(argv[1], NULL, 10);
const uint32_t nEvents = 2;
struct epoll_event events[nEvents];
pthread_t threadID;
const int rc = pthread_create(&threadID, NULL, &start, NULL);
assert(0 == rc);
sleep(1);
std::cout << __PRETTY_FUNCTION__ << ": going to wait for event" <<
std::endl;
int n = epoll_wait(epFD, events, nEvents, -1);
assert(n > 0);
std::cout << "okay" << std::endl;
return 0;
}
Here is how I compiled:
g++ -Wall bug.cpp -o bug -O3 -lpthread
Here is my glibc version:
$ rpm -qa | grep glibc
glibc-devel-2.12-1.132.el6.x86_64
glibc-common-2.12-1.132.el6.x86_64
glibc-2.12-1.132.el6.x86_64
glibc-2.12-1.132.el6.i686
glibc-headers-2.12-1.132.el6.x86_64
Here is my g++ version:
$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
You are receiving this mail because:
You are on the CC list for the bug.