Skip to content

Emacs string is not always a valid utf-8 #58

@kurnevsky

Description

@kurnevsky

I just stumbled upon emacs crash when I do grep in files which contains binary files. In my case emacs calls rust function with file contents which causes the panic. utf-8-validation feature doesn't help much, it only catches invalid string earlier but still panics. Here is the error I have with this feature:

thread '<unnamed>' panicked at /build/fuzzy-matcher-0.0.1-vendor.tar.gz/emacs/src/types/string.rs:16:37:
called `Result::unwrap()` on an `Err` value: FromUtf8Error { bytes: [115, 101, 99, 114, 101, 116, 115, 47, 119, 103, 45, 112, 114, 105, 118, 97, 116, 101, 45, 112, 99, 46, 97, 103, 101, 58, 53, 58, 47, 57, 222, 161, 137, 148, 95, 73, 198, 202, 123, 249, 247, 188, 246, 22, 2, 174, 233, 204, 195, 146, 82, 214, 156, 145, 52, 173, 60, 70, 213, 61, 76, 29, 86, 31, 34, 209, 199, 200, 105, 112, 45, 162, 173, 211, 134, 233, 243, 185, 158, 208, 113, 126, 227, 217, 28, 212, 51, 196], error: Utf8Error { valid_up_to: 32, error_len: Some(1) } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Fatal error 6: Aborted
Backtrace:
/nix/store/4kqc37f77rnk7cgawg696l7zs7bq3bv1-emacs-pgtk-29.4/bin/emacs(emacs_backtrace+0x48) [0x583ab8]
/nix/store/4kqc37f77rnk7cgawg696l7zs7bq3bv1-emacs-pgtk-29.4/bin/emacs(terminate_due_to_signal+0x8b) [0x468179]
/nix/store/4kqc37f77rnk7cgawg696l7zs7bq3bv1-emacs-pgtk-29.4/bin/emacs() [0x4686f2]
/nix/store/4kqc37f77rnk7cgawg696l7zs7bq3bv1-emacs-pgtk-29.4/bin/emacs() [0x581948]
/nix/store/4kqc37f77rnk7cgawg696l7zs7bq3bv1-emacs-pgtk-29.4/bin/emacs() [0x581a49]
/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6(+0x40620) [0x7f87e72de620]
/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6(+0x92a9c) [0x7f87e7330a9c]
/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6(gsignal+0x16) [0x7f87e72de576]
/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6(abort+0xd7) [0x7f87e72c6935]
/nix/store/0iqb54gs5m7w1n2n1lz4kcn3149nin7z-emacs-packages-deps/share/emacs/site-lisp/elpa/fuzzy-matcher-0.0.1/libfuzzy_matcher_el.so(+0x26fba) [0x7f87d00b8fba]

Is there a way to handle such situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions