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

The input isn't verified before using epoll on it #964

Open
cardil opened this issue Mar 25, 2024 · 3 comments
Open

The input isn't verified before using epoll on it #964

cardil opened this issue Mar 25, 2024 · 3 comments

Comments

@cardil
Copy link

cardil commented Mar 25, 2024

Describe the bug

Bubbletea doesn't validate given input, before trying to use epoll on it:

p.cancelReader, err = newInputReader(p.input)

When running processes, Golang (maybe other langs as well?) gives by default the /dev/null as the stdin.

This in turn causes a cryptic epoll error, as the /dev/null doesn't support epoll:

error creating cancelreader: add reader to epoll interest list

You could use muesli/cancelreader#13 to see the underlying syscall.Errno: EPERM. Looking at epoll_ctl(2), the EPERM is returned if:

The target file fd does not support epoll. This error can occur if fd refers to, for example, a regular file or a directory.

Setup

Please complete the following information along with version numbers, if applicable.

  • OS: Linux
  • Shell: zsh
  • Terminal Emulator: Tilix
  • Terminal Multiplexer: none

To Reproduce

Steps to reproduce the behavior:

  1. Checkout the repro: https://github.com/cardil/bubbletea-964
  2. Run test: go test -count=1 ./spin2sec_test.go
  3. You should see TestSpin2SecFailing test failing, with error:
    error creating cancelreader: add reader with descriptor 0 to epoll interest list: operation not permitted
    

Expected behavior

Bubbletea should address a common case of having /dev/null as input, and not feed it to epoll-based reader.

Walk around

To walk away of this problem, one might consider giving an empty buffer as process stdin. See, an example: wavesoftware/go-magetasks@7496084.

@cardil
Copy link
Author

cardil commented Mar 25, 2024

This (most likely) causes the #797

cardil added a commit to cardil/bubbletea-964 that referenced this issue Mar 25, 2024
@cardil cardil changed the title Verify the input before using epoll on it The input isn't verified before using epoll on it Mar 25, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 25, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
cardil added a commit to cardil/knative-client-pkg that referenced this issue Mar 26, 2024
knative-prow bot pushed a commit to knative/client-pkg that referenced this issue Mar 26, 2024
* Bubbletea initialization error handling

* Safe guard for charmbracelet/bubbletea#964
@cardil
Copy link
Author

cardil commented Mar 26, 2024

sourishkrout added a commit to stateful/runme that referenced this issue Apr 5, 2024
Turns out bubbletea errors when handed a non-tty stdin on Linux.

charmbracelet/bubbletea#964

This prevent the `run` command from running into this scenario.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant