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

Multibyte (and/or double width) character problem #34

Closed
s3i7h opened this issue Nov 30, 2021 · 2 comments · Fixed by #37
Closed

Multibyte (and/or double width) character problem #34

s3i7h opened this issue Nov 30, 2021 · 2 comments · Fixed by #37
Labels
bug Something isn't working

Comments

@s3i7h
Copy link

s3i7h commented Nov 30, 2021

I was trying out nsh on my macbook and encountered this. (might be related to #14 ?)

[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/bash_server.rs:26:33
[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'index out of bounds: the len is 20 but the index is 53', /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/mainloop.rs:1153:13
[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs:    0:        0x102083c18 - backtrace::capture::Backtrace::new::hba9adf1e5b3c7a91
   1:        0x10204a7d8 - nsh::main::{{closure}}::h67739294c6afee12
   2:        0x1020ffe9d - std::panicking::rust_panic_with_hook::hae2b05f08a320721
   3:        0x10211dc5c - std::panicking::begin_panic_handler::{{closure}}::h72d68d3a77e0b718
   4:        0x10211dc27 - std::sys_common::backtrace::__rust_end_short_backtrace::h7c5e286792f94edb
   5:        0x10211dbe0 - _rust_begin_unwind
   6:        0x102136d9f - core::panicking::panic_fmt::h1b194bb80d76fb10
   7:        0x102136d66 - core::panicking::panic_bounds_check::hde7f7e34704d5da2
   8:        0x102016118 - nsh::mainloop::Mainloop::handle_key_event::h72f2fc3ed6d69a71
   9:        0x1020119ae - nsh::mainloop::Mainloop::handle_event::h98f98893dfe246aa
  10:        0x10200e02f - nsh::mainloop::Mainloop::run::hd7a071cbdcd9cbdc
  11:        0x1020466e2 - nsh::shell_main::ha315b12f85f157a9
  12:        0x102049ff9 - nsh::main::h367ea8887b771698
  13:        0x101fa32aa - std::sys_common::backtrace::__rust_begin_short_backtrace::hde4e21082195018a
  14:        0x102060794 - _main

[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/bash_server.rs:26:33

I'm in a LANG=ja_JP.UTF-8 environment, and nsh was acting weird in a directory with a name consisting multibyte letters. (The left prompt and the actual input area were separated way apart)
The actual crash occurred when trying to type a letter after completing a multibyte directory name.

PoC:

nsh
$ mkdir ぴーおーしー
$ cd <TAB> <select ぴーおーしー> <return> <type any letter>

(sidenote: ぴーおーしー is "PoC" in Japanese hiragana representation and doesn't mean anything)

@s3i7h
Copy link
Author

s3i7h commented Nov 30, 2021

A different error when trying to choose from the completion list after typing multibyte letter

[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/bash_server.rs:26:33
[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'assertion failed: self.is_char_boundary(n)', /Users/$USER/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/string.rs:1561:29
[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs:    0:        0x101fabc18 - backtrace::capture::Backtrace::new::hba9adf1e5b3c7a91
   1:        0x101f727d8 - nsh::main::{{closure}}::h67739294c6afee12
   2:        0x102027e9d - std::panicking::rust_panic_with_hook::hae2b05f08a320721
   3:        0x102045c5c - std::panicking::begin_panic_handler::{{closure}}::h72d68d3a77e0b718
   4:        0x102045c27 - std::sys_common::backtrace::__rust_end_short_backtrace::h7c5e286792f94edb
   5:        0x102045be0 - _rust_begin_unwind
   6:        0x10205ed9f - core::panicking::panic_fmt::h1b194bb80d76fb10
   7:        0x10205ecf7 - core::panicking::panic::hdb9dddaff64fd68b
   8:        0x101f45674 - nsh::mainloop::Mainloop::select_completion::h070c0693897dce31
   9:        0x101f3a94a - nsh::mainloop::Mainloop::handle_key_event::h72f2fc3ed6d69a71
  10:        0x101f399ae - nsh::mainloop::Mainloop::handle_event::h98f98893dfe246aa
  11:        0x101f3602f - nsh::mainloop::Mainloop::run::hd7a071cbdcd9cbdc
  12:        0x101f6e6e2 - nsh::shell_main::ha315b12f85f157a9
  13:        0x101f71ff9 - nsh::main::h367ea8887b771698
  14:        0x101ecb2aa - std::sys_common::backtrace::__rust_begin_short_backtrace::hde4e21082195018a
  15:        0x101f88794 - _main

[ERROR	] /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/main.rs: panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /Users/$USER/.cargo/registry/src/github.com-1ecc6299db9ec823/nsh-0.4.2/src/bash_server.rs:26:33

@nuta
Copy link
Owner

nuta commented Nov 30, 2021

Thanks for reporting the issue, @yu-ichiro! As you mentioned it's similar to #14, but I guess it's another wide-width character handling bug.

@nuta nuta added the bug Something isn't working label Nov 30, 2021
@nuta nuta closed this as completed in #37 Dec 13, 2021
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

Successfully merging a pull request may close this issue.

2 participants