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

thread 'main' panicked at 'byte index 1 is not a char boundary #971

Closed
flodolo opened this issue Jul 4, 2019 · 8 comments · Fixed by #978
Closed

thread 'main' panicked at 'byte index 1 is not a char boundary #971

flodolo opened this issue Jul 4, 2019 · 8 comments · Fixed by #978
Labels
C-dependency-bug Category: A bug in a dependency

Comments

@flodolo
Copy link

flodolo commented Jul 4, 2019

I'm running mdBook 0.3 on macOS, and for some reasons it fails to build one of the file containing the ë character. The thing I don't understand is that I have other files with that character, and they build just fine.

Minimal file content in README.md

# Test

spatiëring.

Error

2019-07-04 11:52:26 [INFO] (mdbook::book): Book building has started
2019-07-04 11:52:26 [INFO] (mdbook::book): Running the html backend
thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'ë' (bytes 0..2) of `ër`', src/libcore/str/mod.rs:2027:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@flodolo
Copy link
Author

flodolo commented Jul 4, 2019

Additional note: it doesn't seem to happen if the content of the file is just

spatiëring.

@zbraniecki
Copy link

Any chance you can run it with RUST_BACKTRACE=1 to get the trace?

@flodolo
Copy link
Author

flodolo commented Jul 5, 2019

thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'ë' (bytes 0..2) of `ër`', src/libcore/str/mod.rs:2027:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::str::slice_error_fail
   9: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}
  10: elasticlunr::lang::en::stemmer
  11: elasticlunr::pipeline::Pipeline::run
  12: elasticlunr::Index::add_doc
  13: mdbook::renderer::html_handlebars::search::add_doc
  14: mdbook::renderer::html_handlebars::search::create_files
  15: <mdbook::renderer::html_handlebars::hbs_renderer::HtmlHandlebars as mdbook::renderer::Renderer>::render
  16: mdbook::book::MDBook::build
  17: mdbook::cmd::build::execute
  18: mdbook::main
  19: std::rt::lang_start::{{closure}}
  20: std::panicking::try::do_call
  21: __rust_maybe_catch_panic
  22: std::rt::lang_start_internal
  23: main

@zbraniecki
Copy link

Ok, seems to be a bug in https://github.com/mattico/elasticlunr-rs

Basically, it doesn't expect english to use non-latin characters.

The kind of code that triggers the crash is https://github.com/mattico/elasticlunr-rs/blob/master/src/lang/en.rs#L213

It should instead use a safe slicing, and likely a different regexp.

@flodolo
Copy link
Author

flodolo commented Jul 5, 2019

Thanks for digging. I assume the best next step is to report the issue in the other repository?

@bwinton
Copy link

bwinton commented Jul 5, 2019

I've made a pull request to elasticlunr-rs that looks like it'll fix this issue.

[Edited to add: Oh no, there are more… I'll have to update my PR.]
[Further edit: Wait, no, those are all indexing into a Captures struct. I think my PR might be fine…]

@zbraniecki
Copy link

Thanks Blake! That looks like a good fix.

@ehuss ehuss added the C-dependency-bug Category: A bug in a dependency label Jul 9, 2019
@bwinton
Copy link

bwinton commented Jul 11, 2019

And the PR has landed, so hopefully this will be fixed when we pull in the next version of that library! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-dependency-bug Category: A bug in a dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants