Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: EPERM for epoll_ctl() on every os.Open #44552

Closed
mark-kubacki opened this issue Feb 23, 2021 · 2 comments
Closed

runtime: EPERM for epoll_ctl() on every os.Open #44552

mark-kubacki opened this issue Feb 23, 2021 · 2 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mark-kubacki
Copy link

go version go1.16

  • Linux 5.10 and 5.4
  • xfs and ext4

attempts two useless epoll_ctl on every os.Open ,
either indicating that the epoll facility does not work for files, or an check is missing to turn it off as it is without any back-off.

I ran this under strace, as unprivileged user and root without difference, …

package main

import (
	"bytes"
	"fmt"
	"os"
)

func main() {
	f, _ := os.Open("/etc/os-release")
	//_ = f.Fd()
	var b bytes.Buffer
	n, _ := b.ReadFrom(f)
	f.Close()

	f, _ = os.Open("/etc/os-release")
	n, _ = b.ReadFrom(f)
	f.Close()

	fmt.Printf("in: %d\n", n)
}

… expecting this trailer (edited):

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
… (Either no epoll_ctl, or no EPERM.) …
… read(3, …
close(3)                                = 0

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
… (No epoll_ctl in any case, due to the preceding EPERM.) …
… read(3, …
close(3)                                = 0

… yet witnessed this (please note the EPERM):

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=3290965168, u64=140337052394672}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 3, 0xc00025fd4c) = -1 EPERM (Operation not permitted)
… read(3, …
close(3)                                = 0

openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=3290965168, u64=140337052394672}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 3, 0xc00025fd4c) = -1 EPERM (Operation not permitted)
… read(3, …
close(3)                                = 0
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 23, 2021
@ianlancetaylor
Copy link
Contributor

The os package doesn't know apriori which files support epoll. So it just tries to use epoll for every file.

It does seem like we don't need the EPOLL_CTL_DEL if the EPOLL_CTL_ADD fails, though.

@ianlancetaylor ianlancetaylor added this to the Backlog milestone Feb 23, 2021
@gopherbot
Copy link

Change https://golang.org/cl/297392 mentions this issue: internal/poll, runtime: handle netpollopen error in poll_runtime_pollOpen

@golang golang locked and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants