This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ZackerySpytz, benjamin.peterson, nikratio, skrah, vstinner
Date 2020-01-06.16:20:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578327630.8.0.617729237277.issue35561@roundup.psfhosted.org>
In-reply-to
Content
On my Fedora 31, epoll_event structure is defined in sys/epoll.h as:

typedef union epoll_data
{
  void *ptr;
  int fd;
  uint32_t u32;
  uint64_t u64;
} epoll_data_t;

struct epoll_event
{
  uint32_t events;	/* Epoll events */
  epoll_data_t data;	/* User data variable */
} __EPOLL_PACKED;


I can reproduce the issue using this Python script:

import select
p = select.epoll()
p.register(1, select.EPOLLIN)
p.poll(0)

The Linux syscall is defined as:

asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
				struct epoll_event __user *event);

It's implemented in fs/eventpoll.c:

https://github.com/torvalds/linux/blob/c79f46a282390e0f5b306007bf7b11a46d529538/fs/eventpoll.c#L2077-L2083

Valgrind complains that ev.data is only partially initialized: it's a 64-bit structure, but we only set ev.data.fd. I guess that the glibc implements epoll_ctl() as a raw system call: Valgrind is unable to know if it's ok to only partially initialize the epoll_data union.


Benjamin: "I suspect Valgrind is being too conservative. union epoll_data is 64 bits wide but the file descriptor only occupies the first 32 bits. The last 32 bits don't need to be initialized by the application."

Right. But Valgrind is not smart enough.

I see 2 options:

* Initialize ev.data to 0
* Use Misc/valgrind-python.supp to ignore this *false alarm*
History
Date User Action Args
2020-01-06 16:20:30vstinnersetrecipients: + vstinner, benjamin.peterson, nikratio, skrah, ZackerySpytz
2020-01-06 16:20:30vstinnersetmessageid: <1578327630.8.0.617729237277.issue35561@roundup.psfhosted.org>
2020-01-06 16:20:30vstinnerlinkissue35561 messages
2020-01-06 16:20:30vstinnercreate