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

Ropey char index out of bounds panic #12461

Open
gibbz00 opened this issue Jan 9, 2025 · 7 comments
Open

Ropey char index out of bounds panic #12461

gibbz00 opened this issue Jan 9, 2025 · 7 comments
Labels
C-bug Category: This is a bug

Comments

@gibbz00
Copy link
Contributor

gibbz00 commented Jan 9, 2025

Summary

Getting a panic when copying some EBNF from a PDF and then inserting some newlines into it. (https://standards.scheme.org/official/r7rs.pdf p. 62 if it helps.)

Reproduction Steps

Tried to enter a newline at every | after pasting the following:

real R〉 | 〈real R〉 @ 〈real R〉
| 〈real R〉 + 〈ureal R〉 i | 〈real R〉 - 〈ureal R〉 i
| 〈real R〉 + i | 〈real R〉 - i | 〈real R〉 〈infnan〉 i
| + 〈ureal R〉 i | - 〈ureal R〉 i
| 〈infnan〉 i | + i | - i

https://asciinema.org/a/gIJF8EpZ9wTsOGTxHWbX7NKgk

Helix log

Stderr

thread 'main' panicked at /build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:360:41:
called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 220, Rope/RopeSlice char length 219
stack backtrace:
   0:     0x5c1d5077f278 - <unknown>
   1:     0x5c1d4f94c2d3 - <unknown>
   2:     0x5c1d5077a553 - <unknown>
   3:     0x5c1d5077f0c2 - <unknown>
   4:     0x5c1d50780ea8 - <unknown>
   5:     0x5c1d50780cee - <unknown>
   6:     0x5c1d507815a9 - <unknown>
   7:     0x5c1d5078130a - <unknown>
   8:     0x5c1d5077f739 - <unknown>
   9:     0x5c1d50780f9c - <unknown>
  10:     0x5c1d4f8598f0 - <unknown>
  11:     0x5c1d4f859cf6 - <unknown>
  12:     0x5c1d4fbd4727 - <unknown>
  13:     0x5c1d4fbc0eda - <unknown>
  14:     0x5c1d4fbc2c3c - <unknown>
  15:     0x5c1d50463805 - <unknown>
  16:     0x5c1d50463fc9 - <unknown>
  17:     0x5c1d5031264f - <unknown>
  18:     0x5c1d50002726 - <unknown>
  19:     0x5c1d5000267e - <unknown>
  20:     0x5c1d500028c1 - <unknown>
  21:     0x5c1d5000538b - <unknown>
  22:     0x5c1d4fff55ae - <unknown>
  23:     0x5c1d504f343e - <unknown>
  24:     0x5c1d504f0be9 - <unknown>
  25:     0x5c1d50549546 - <unknown>
  26:     0x5c1d50525b39 - <unknown>
  27:     0x5c1d5058ace6 - <unknown>
  28:     0x5c1d5056dc51 - <unknown>
  29:     0x5c1d507718b7 - <unknown>
  30:     0x5c1d50525d24 - <unknown>
  31:     0x73e8748a0e08 - <unknown>
  32:     0x73e8748a0ecc - __libc_start_main
  33:     0x5c1d4f8c4de5 - <unknown>
  34:                0x0 - <unknown>

Logs

2025-01-09T16:36:54.280 helix_term::application [DEBUG] received editor event: IdleTimer
2025-01-09T16:36:54.513 helix_term::commands [TRACE] entering insert mode with sel: Selection { ranges: [Range { anchor: 35, head: 36, old_visual_position: None }, Range { anchor: 82, head: 83, old_visual_position: None }, Range { anchor: 122, head: 123, old_visual_position: None }, Range { anchor: 137, head: 138, old_visual_position: None }, Range { anchor: 175, head: 176, old_visual_position: None }, Range { anchor: 204, head: 205, old_visual_position: None }, Range { anchor: 210, head: 211, old_visual_position: None }], primary_index: 0 }, text: "pub struct Number(Number);\nreal R〉 | 〈real R〉 @ 〈real R〉\n| 〈real R〉 + 〈ureal R〉 i | 〈real R〉 - 〈ureal R〉 i\n| 〈real R〉 + i | 〈real R〉 - i | 〈real R〉 〈infnan〉 i\n| + 〈ureal R〉 i | - 〈ureal R〉 i\n| 〈infnan〉 i | + i | - i"
2025-01-09T16:36:54.513 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2025-01-09T16:36:54.515 helix_term::application [DEBUG] received editor event: IdleTimer
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711633680: [IndentCapture { capture_type: Indent, scope: Tail }], 95912708964336: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598032: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598032: [IndentCapture { capture_type: Indent, scope: Tail }], 95912708964336: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711633680: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598032: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711633680: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598032: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912709598576: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709601536: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912709600320: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.706 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.707 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711007696: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711006496: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.707 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.707 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.707 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {}, extend_captures: {} }
2025-01-09T16:36:54.707 helix_core::indent [TRACE] indent result = IndentQueryResult { indent_captures: {95912711009024: [IndentCapture { capture_type: Indent, scope: Tail }], 95912711010272: [IndentCapture { capture_type: Indent, scope: Tail }]}, extend_captures: {} }
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.708 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.709 helix_lsp::transport [ERROR] err: <- Other(failed to send a message to server

Caused by:
    channel closed

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>)
2025-01-09T16:36:54.709 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.709 helix_lsp::transport [ERROR] scls err: <- StreamClosed
2025-01-09T16:36:54.709 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller
2025-01-09T16:36:54.710 mio::poll [TRACE] deregistering event source from poller

Platform

Linux

Terminal Emulator

foot version: 1.17.2 +pgo +ime +graphemes -assertions

Installation Method

arch repo with paru

Helix Version

helix 25.1

@gibbz00 gibbz00 added the C-bug Category: This is a bug label Jan 9, 2025
@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 9, 2025

Hm... I can't reproduce this on the latest master.
What I did was selecting the vertical bars as you did (select filter: \|) afterwards I pressed r<ret> but that worked fine.
Also a<ret> worked fine for me.
Hm... may I ask if you can provide some minimal reproduction steps? Am I doing something wrong?

@gibbz00
Copy link
Contributor Author

gibbz00 commented Jan 9, 2025

Sorry, realised that I forgot to mention the selection collapse before inserting return. (Visible in the asciinema though.) You're correct in that it does not reproduce the error if left out.

@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 9, 2025

Hm even if I collapse the selection (I hope we talk about the same by pressing ;) I'm getting no panic:

recording-2025-01-09_19.39.20.mp4

@gibbz00
Copy link
Contributor Author

gibbz00 commented Jan 9, 2025

Yeah, `;' should be right. (I've got mine bound to escape.)

How did you paste in the snippet? I think you need to paste it on an "EOF line that does not yet exist". See how I in the recording paste it at the ~ line.

@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 9, 2025

Alright, so here's a full video of my steps:

recording-2025-01-09_19.53.19.mp4

I'm currently on the master branch. May I ask if you can try the latest master branch as well?

@gibbz00
Copy link
Contributor Author

gibbz00 commented Jan 9, 2025

Still not pasting onto the last line. Notice how I go down one line down in my recording before pasting. 😊

No, official release, as mentioned in the top comment.

@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 9, 2025

Ok, I think that I'm too stupid for this....

bonk

maybe someone else should investigate this

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

No branches or pull requests

2 participants