diff-match-patch-c icon indicating copy to clipboard operation
diff-match-patch-c copied to clipboard

Infinite loop in diff_cleanup_merge()

Open errzey opened this issue 12 years ago • 2 comments

While I am still actively debugging this, it would be nice to get a second set of eyes on this:

Take file a

a
bcde

Then file b

A
bcdefghijklmnopqrs

The process works as expected:

> "a\x0abcde\x0a"
-"a", +"A", ="\x0abcde", +"fghijklmno", ="\x0a"
< "A\x0abcdefghijklmnopqrs\x0a"

But if you add one more character to the second line of file b (note the trailing t)

A
bcdefghijklmnopqrst

The third iteration of diff_cleanup_merge() will never hit i != -1

As I've stated, I'm actively debugging this, but just thought you might want to know.

errzey avatar Nov 28 '13 01:11 errzey

I think I ran into the same problem. I have a specific pattern (more complex that yours) that locks the diff algorithm up, but removing the diff_cleanup_merge() call avoids the deadlock. @elizey, did you have any progress with this? At least it looks like the bug is in diff_cleanup_merge() which is pretty much self contained and doesn't require knowledge about the diff algorithm itself.

udif avatar May 15 '16 19:05 udif

Fixed :-) See PR above.

udif avatar May 15 '16 22:05 udif