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

[BUG] application freezed, does not respond to keyboard/mouse input. #41

Closed
zhanglei002 opened this issue Sep 26, 2021 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@zhanglei002
Copy link

Describe the bug

[A clear and concise description of what the bug is.]

To Reproduce

randomly scroll process list.

Expected behavior

[A clear and concise description of what you expected to happen.]

Screenshots

[If applicable, add screenshots to help explain your problem.]

Info (please complete the following information):

  • btop++ version: master
  • Binary: self compiled
  • (If compiled) Compiler and version:gcc version 11.1.0 (GCC)
  • Architecture: [x86_64, aarch64, etc.] x86_64
  • Platform: Linux
  • (Linux) Kernel: 5.14.0-0-MANJARO
  • (OSX/FreeBSD) Os release version:
  • Terminal used: iterm2/fish
  • Font used:

Additional context

contents of ~/.config/btop/btop.log

(try running btop with --debug flag if error.log is empty)

GDB Backtrace

Thread 2 (LWP 2749 "btop"):
#0 0x00007f2bc7bd0a9d in syscall () from /usr/lib/libc.so.6
#1 0x0000563a794fda5e in void std::__detail::__platform_wait(int const*, int) ()
#2 0x0000563a795516c7 in Runner::_runner(void*) ()
#3 0x00007f2bc7cad299 in start_thread () from /usr/lib/libpthread.so.0
#4 0x00007f2bc7bd6053 in clone () from /usr/lib/libc.so.6
Thread 1 (LWP 2748 "btop"):
#0 0x00007f2bc7cb687c in read () from /usr/lib/libpthread.so.0
#1 0x00007f2bc7eed662 in std::__basic_file::xsgetn (this=this@entry=0x7f2bc8037b08 <__gnu_internal::buf_cin+104>, __s=0x563a7996ddd0 "\033[A0;122;33m\033[<0;114;34m\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M\033[<65;97;45M", __n=__n@entry=8191) at basic_file.cc:331
#2 0x00007f2bc7f2eb61 in std::basic_filebuf<char, std::char_traits >::underflow (this=0x7f2bc8037aa0 <__gnu_internal::buf_cin>) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/streambuf:487
#3 0x00007f2bc7ec7ee1 in std::basic_streambuf<char, std::char_traits >::sgetc (this=0x7f2bc8037aa0 <__gnu_internal::buf_cin>) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/streambuf:343
#4 std::basic_streambuf<char, std::char_traits >::sgetc (this=) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/streambuf:343
#5 std::basic_streambuf<char, std::char_traits >::snextc (this=) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/streambuf:308
#6 std::istream::ignoreXX (this=0x7f2bc80385a0 std::cin, __n=9223372036854775807) at /build/gcc/src/gcc/libstdc++-v3/src/c++98/compatibility.cc:96
#7 0x0000563a7951fa67 in Input::getabi:cxx11 ()
#8 0x0000563a794e2abd in main ()

@zhanglei002 zhanglei002 added the bug Something isn't working label Sep 26, 2021
@aristocratos
Copy link
Owner

@zhanglei002
Does this happen immediately on input? If not, how long to it happens usually?

With scrolling do you mean with the up/down keys or with mouse scroll?

Also would mind downloading the precompiled static binary from the release and see if it causes the same issue on your system?

It looks to be happening when trying to clear any reamaining input in stdin after reading a key, on line 98:

btop/src/btop_input.cpp

Lines 97 to 98 in 5ae05f0

while (cin.rdbuf()->in_avail() > 0 and key.size() < 100) key += cin.get();
if (cin.rdbuf()->in_avail() > 0) cin.ignore(SSmax);

SSmax is:

constexpr auto SSmax = std::numeric_limits<std::streamsize>::max();

The while loop should be guarded from infinity by only reading max 100 characters but not sure why the ignore function gets stuck.

And thanks for the great backtrace :)

@zhanglei002
Copy link
Author

Does this happen immediately on input? If not, how long to it happens usually?

Not immediately. Not sure, sometimes.

With scrolling do you mean with the up/down keys or with mouse scroll?

it seems it can be easily reproduced with mouse scroll(touchpad in my case).

Also would mind downloading the precompiled static binary from the release and see if it causes the same issue on your system?

can also be reproduced with precompiled static binary.

@aristocratos
Copy link
Owner

@zhanglei002
I've changed the offending line to

if (cin.rdbuf()->in_avail() > 0) cin.ignore(cin.rdbuf()->in_avail());

I think the issue might be that line would have always gotten stuck, but in 99% of cases it never gets reached because it's hard to create more than 100 characters in less time than the program can read them.

Your thouchpad might be doing something weird like instead of actually emulating a mouse scroll, generating a bunch keyboard commands?

Try with latest commit.

@zhanglei002
Copy link
Author

Thanks for the quick fix!
I have tried with the latest commit, it worked without any problem.

@aristocratos
Copy link
Owner

No problem :)

Thanks for the great debugging, would have been a very hard solve without it.

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

No branches or pull requests

2 participants