altsem / gitu

A TUI Git client inspired by Magit
MIT License
1.83k stars 94 forks source link

Os Error #22

Closed failable closed 8 months ago

failable commented 8 months ago

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 $ 
altsem commented 8 months ago

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

failable commented 8 months ago

Seems to get the same output..

image
altsem commented 8 months ago

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!

overhacked commented 8 months ago

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: https://github.com/altsem/gitu/blob/9d601249f7eff2ddbfd0f58a98af1204b3a876c1/src/lib.rs#L218-L226

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 commented 8 months ago

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 commented 8 months ago

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

altsem commented 8 months ago

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! :)