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

Os Error #22

Closed
failable opened this issue Mar 4, 2024 · 7 comments
Closed

Os Error #22

failable opened this issue Mar 4, 2024 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@failable
Copy link

failable commented Mar 4, 2024

When I try to run gitu, I get the below error.

user@macos:~/Downloads/gitu $ gitu
Error: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }
user@macos:~/Downloads/gitu $ 
  • OS: macOS 14.2.1 (23C71)
  • Version: cargo install --git https://github.com/altsem/gitu.git --locked # 6196acc
@altsem
Copy link
Owner

altsem commented Mar 4, 2024

This looks like a cryptic message from libgit2.
What does it say when you
RUST_BACKTRACE=1 cargo run?

@failable
Copy link
Author

failable commented Mar 4, 2024

Seems to get the same output..
image

@altsem
Copy link
Owner

altsem commented Mar 4, 2024

Been on rustc 1.76 (stable), switched to 1.78 (nightly) and I got these warnings as well. But I don't experience the same issue on Fedora.
Should add some logging options to Gitu. Best I can do here is guess.

Thank you for reporting it!

@altsem altsem added bug Something isn't working help wanted Extra attention is needed labels Mar 4, 2024
@overhacked
Copy link

I've been banging away at this, and the problem is that Duration::MAX is too large for the select(2) syscall timeout value (at least on macOS). select() gets called in the main loop via event::poll:

gitu/src/lib.rs

Lines 218 to 226 in 9d60124

while !state.quit {
// TODO Gather all events, no need to draw for every
if !event::poll(std::time::Duration::MAX)? {
continue;
}
let event = event::read()?;
update(terminal, &mut state, &[event])?;
}

I think that this call to event::poll() is unnecessary, because giving it a maximum, effectively infinite timeout, makes it blocking, just like event::read(). Can the main loop just omit the if (poll) then continue condition and block on event::read() (delete lines 219-222)? I don't see any work that is currently being performed between calls to poll, anyway.

Note: I found that the syscall call was the source of the problem by stepping through with a debugger, and I figured out the maximum value for the timeout to select(2) on macOS with the following sloppy C code: https://gist.github.com/overhacked/0b041af7994c06f9b6837876083deb72

@overhacked
Copy link

I meant to add, commenting out

     if !event::poll(std::time::Duration::MAX)? { 
         continue; 
     } 

gets rid of the error, and everything else in the TUI seems to work fine.

@altsem
Copy link
Owner

altsem commented Mar 4, 2024

Agreed it looks entirely unnecessary. There's no need to draw unless there's an event. 👍

@altsem
Copy link
Owner

altsem commented Mar 4, 2024

I merged a fix for it for now, reckon i need to see over PR permissions or something so others can contribute more easily. Assuming this fixes it and closing the issue.
Thanks guys! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants