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 diffing text #681

Closed
davidselassie opened this issue Mar 26, 2024 · 2 comments
Closed

Panic diffing text #681

davidselassie opened this issue Mar 26, 2024 · 2 comments

Comments

@davidselassie
Copy link

I'm not totally sure what about the first or second content is causing this, but I'm diffing two Markdown files (which are detected as text files) and get a panic. Using Difftastic 0.56.1 (built with rustc 1.74.1) on Ubuntu.

dsel@lemur ~/panictest (main) [101]> RUST_BACKTRACE=1 difft custom-connectors-old.md custom-connectors-new.md
custom-connectors.md --- Text
12 Also check out some of our built-in custom connectors  12 Also check out some of our built-in custom connectors 
.. in                                                     .. in
13 {py:obj}`bytewax.connectors` and looking at the source 13 {py:obj}`bytewax.connectors` and looking at the source
..  for how they                                          ..  for how they
14 are implemented.                                       14 are implemented.
thread 'main' panicked at /home/dsel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/difftastic-0.56.1/src/display/side_by_side.rs:505:34:
index out of bounds: the len is 14 but the index is 14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_bounds_check
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:180:5
   3: difft::display::side_by_side::print
   4: difft::print_diff_result
   5: difft::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I have tried to make a minimum reproduction. But removing seemingly any of the content from the new file does not cause a panic. Files here:

custom-connectors-new.md
custom-connectors-old.md

@Jorispilot
Copy link

I got the same “out of bounds” issue on a ~500 lines csv file interpreted as text, but not at the same place in the code :

thread 'main' panicked at src/display/side_by_side.rs:505:34:
index out of bounds: the len is 462 but the index is 462

JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 5, 2024
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 5, 2024
This one fixes Wilfred#681.

The previous one didn't fixed the very specific case of Wilfred#681
with the provided csv, this one does.
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 5, 2024
This one fixes Wilfred#681.

The previous one didn't fixed the very specific case of Wilfred#681
with the provided csv, this one does.
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 5, 2024
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 5, 2024
This one fixes Wilfred#681.

The previous one didn't fixed the very specific case of Wilfred#681
with the provided csv, this one does.
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 6, 2024
Fixes Wilfred#688, fixes Wilfred#694, fixes Wilfred#682 and fixes Wilfred#681.

This works around the fact that `str::lines` does not include last
newline character.
This means that `"a\n".lines().count() == "a".lines().count()`, which
breaks the 1:1 assumption made by display implementations.
JonathanxD added a commit to JonathanxD/difftastic that referenced this issue Apr 6, 2024
Fixes Wilfred#688, fixes Wilfred#694, fixes Wilfred#682 and fixes Wilfred#681.

This works around the fact that `str::lines` does not include last
newline character.
This means that `"a\n".lines().count() == "a".lines().count()`, which
breaks the 1:1 assumption made by display implementations.
@Wilfred
Copy link
Owner

Wilfred commented May 12, 2024

Merging into #688, thanks for the report!

@Wilfred Wilfred closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants