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

Panic on weird n" in a Rust file #7468

Closed
mo8it opened this issue Jun 27, 2023 · 6 comments · Fixed by #7471
Closed

Panic on weird n" in a Rust file #7468

mo8it opened this issue Jun 27, 2023 · 6 comments · Fixed by #7471
Labels
C-bug Category: This is a bug

Comments

@mo8it
Copy link
Contributor

mo8it commented Jun 27, 2023

Summary

I was writing the following line in Rust:

writeln!(writer, "{}\n", positions.len())?;

After entering \n, the editor crashed!

The panic is from the following line:

panic!("Positions {out_of_bounds:?} are out of range for changeset len {old_pos}!",)

Reproduction Steps

I found a minimal (and very weird) example to reproduce this bug:

  1. Run the commands
    1. cargo new project
    2. cd project
    3. echo 'n"' > src/main.rs
    4. hx src/main.rs
  2. Wait for the language server to start.
  3. Press c over the character n to change it.
  4. Helix crashes with the following error:
    thread 'main' panicked at 'Positions [(1, After), (1, After)] are out of range for changeset len 2!', /var/home/mo/code/compile/helix/helix-core/src/transaction.rs:413:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

Helix log

~/.cache/helix/helix.log
2023-06-27T16:20:03.976 helix_view::document [WARN] LSP formatting failed: protocol error: ServerError(-32900): rustfmt exited with:
                           Status: exit status: 101
                           stdout: 
                           stderr: error: prefix `n` is unknown
 --> <stdin>:1:1
  |
1 | n"
  | ^ unknown prefix
  |
  = note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
  |
1 | n "
  |  +

error[E0765]: unterminated double quote string
 --> <stdin>:1:2
  |
1 | n"
  |  ^^

Platform

Linux

Terminal Emulator

Alacritty 0.12.1

Helix Version

helix 23.05 (d511122)

@mo8it mo8it added the C-bug Category: This is a bug label Jun 27, 2023
@mo8it
Copy link
Contributor Author

mo8it commented Jun 27, 2023

@pascalkuthe @archseer This should be the buggy commit: d491e23

@mo8it
Copy link
Contributor Author

mo8it commented Jun 27, 2023

Explicit panic in an editor does not sound like a good idea :/

@archseer
Copy link
Member

Your helix version points to a commit from last month though? Can you try with the fix that has since landed in master 8d39a81

@mo8it
Copy link
Contributor Author

mo8it commented Jun 27, 2023

Then hx --version is stuck on that commit. I did just make sure:

code/compile/helix on  master
❯ git pull -r && cargo +stable install --path helix-term
Already up to date.
  Installing helix-term v0.6.0 (/var/home/mo/code/compile/helix/helix-term)
    Updating crates.io index
    Finished release [optimized] target(s) in 2.57s
   Replacing /var/home/mo/.cargo/bin/hx
    Replaced package `helix-term v0.6.0 (/var/home/mo/code/compile/helix/helix-term)` with `helix-term v0.6.0 (/var/home/mo/code/compile/helix/helix-term)` (executable `hx`)
                                                                                                                                                                                                                   
code/compile/helix on  master took 3s
❯ hx --version
helix 23.05 (d5111222)
                                                                                                                                                                                                                   
code/compile/helix on  master
❯ git log -n 1
commit d8f9b901ddb1d91bf3ade66cf091e93b5cab6e49 (HEAD -> master, origin/master, origin/HEAD)
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jun 27 15:37:22 2023 +0200
                                                                                                                                                                                                                   
    build(deps): bump libc from 0.2.146 to 0.2.147 (#7463)
                                                                                                                                                                                                                   
    Bumps [libc](https://github.com/rust-lang/libc) from 0.2.146 to 0.2.147.
    - [Release notes](https://github.com/rust-lang/libc/releases)
    - [Commits](https://github.com/rust-lang/libc/compare/0.2.146...0.2.147)
                                                                                                                                                                                                                   
    ---
    updated-dependencies:
    - dependency-name: libc
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
                                                                                                                                                                                                                   
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

❯ ls -l (which hx)
.rwxr-xr-x@ 26M USER 2023-06-27 16:32 /var/home/mo/.cargo/bin/hx

@pascalkuthe
Copy link
Member

I can reproduce i will look into fix

@mo8it
Copy link
Contributor Author

mo8it commented Jun 27, 2023

@pascalkuthe Thank you!

@archseer Should I open an issue about hx --version?

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

Successfully merging a pull request may close this issue.

3 participants