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

avoid negative repeat_count fixes #1760 #1766

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lrfurtado
Copy link

No description provided.

src/paint.rs Outdated Show resolved Hide resolved
@th1000s
Copy link
Collaborator

th1000s commented Jul 18, 2024

Nice find, interesting that this unsigned underflow was never triggered before.

Can you provide a minimal example diff which triggers this so it can be called with cat diff.txt | delta --no-gitconfig --width=X? I assume the current terminal width is a contributing factor, so --width should make it independent of that. Then a test with insta's assert_snapshot! can be written to ensure that never happens again.

@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from fffa015 to 1e3e9bc Compare July 18, 2024 13:37
@lrfurtado
Copy link
Author

lrfurtado commented Jul 18, 2024

commit XXXXXXXXXXXXXXXXXXXXXXXXX
Author: LUCIANO FURTADO <[email protected]>
Date:   Tue Jun 25 14:07:31 2024 -0500

    Ref: https://github.com/dandavison/delta/issues/1760

diff --git a/foobar b/foobar
index 185a33cd5b..123f893935 100755
--- a/foobar
+++ b/foobar
@@ -14,6 +14,11 @@ function UNDERFLOW_EXEC() {
    XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX  
 }

+
+
+echo "=== VALIDATE UNDERFLOW"
+/usr/local/bin/check_underflow
+
 # this is an example of the underflow error
 echo "=== UNDERFLOW_EXEC"
 UNDERFLOW_EXEC -i foobar.yaml


@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from 1e3e9bc to ad812b8 Compare July 18, 2024 20:53
@lrfurtado
Copy link
Author

@th1000s are my latest changes what you had in mind ?

@th1000s
Copy link
Collaborator

th1000s commented Jul 20, 2024

Yes, however when keeping the test and reverting your fix, then running cargo test test_long_line_underflow -- --nocapture does not trigger the crash. But this BgFillMethod::Spaces code path is quite hard to it, I could not do it after trying a few parameters.

Can you reproduce this when piping your example input into the delta (debug build) binary? And can you reproduce this when specifying --no-gitconfig and then adding the settings from your git config manually? And then, what is your terminal width: echo $COLUMNS.

@lrfurtado
Copy link
Author

found something interesting no crash with --no-gitconfig

image

It's something on my gitconfig + the diff on the test that causes causes the crash.

image

The part of my gitconfig related to delta is:

image

@lrfurtado
Copy link
Author

The options causing the problem seems to be
image

@lrfurtado
Copy link
Author

without the saturating_sub the test now crashes
image

@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from ad812b8 to a0d0786 Compare July 23, 2024 16:52
@lrfurtado
Copy link
Author

@th1000s I think it looks better now

@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from a0d0786 to 38df306 Compare July 24, 2024 16:23
@lrfurtado
Copy link
Author

@th1000s I think it looks better now

Found something interesting @th1000s --width 111 is not fully insulating the unitest from terminal sizes differences, if I increase or decrease the size of the font on my terminal. The tests start breaking.

@th1000s
Copy link
Collaborator

th1000s commented Jul 29, 2024

Nice, thank you for the investigation, looks like styling zero hunks is not tested enough. And because of this other bug you found (but is now nicely reproducible) let's just add #[ignore] to the #[test].

And when you set the expected output in assert_snapshot!(..) try setting your terminal to 111 so it is as it should be. Also, cargo fmt will take care of the code formatting.

src/tests/test_example_diffs.rs Outdated Show resolved Hide resolved
Comment on lines +3169 to +3178
+
+echo "=== VALIDATE UNDERFLOW"
+/usr/local/bin/check_underflow
+
# this is an example of the underflow error
echo "=== UNDERFLOW_EXEC"
UNDERFLOW_EXEC -i foobar.yaml

"#;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave out almost all of these +- lines, as you found out the context before the changed lines was the cause.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any concerns leaving as is ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it makes the minimal reproducer diff larger than it has to be, and the text sort of indicates that it's these lines. As you have to rebase anyhow to make it build with rust 1.80, maybe you can also trim the added lines down to one or two.

@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from 38df306 to 0fcdd92 Compare August 1, 2024 00:52
@lrfurtado lrfurtado force-pushed the fix-1760-capacity-overflow branch from 0fcdd92 to 9c4f98a Compare August 1, 2024 13:59
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

Successfully merging this pull request may close these issues.

2 participants