6.0.0-git
2018-12-15

[#14738] Failed asserts in Text_Diff in 'native' engine
Summary Failed asserts in Text_Diff in 'native' engine
Queue Horde Framework Packages
Type Bug
State Feedback
Priority 2. Medium
Owners
Requester cpigott (at) rapitasystems (dot) com
Created 2017-11-24 (386 days ago)
Due
Updated 2018-09-23 (83 days ago)
Assigned 2018-01-22 (327 days ago)
Resolved
Milestone
Patch No

History
2018-09-23 19:07:58 dwayne (dot) towell (at) gmail (dot) com Comment #4 Reply to this comment

$a="a =
print (a)
print ()
print (a)
print ()
print (a)

";
$b = "a =
print ()
print (a)
print ()
print (a)
print ()

";
$diff = new Horde_Text_Diff('auto',[explode("\n",$a),explode("\n",$b)]);

produces:

PHP Warning:  assert(): assert($y <= $this->seq[$k]) failed in 
/usr/share/pear/Horde/Text/Diff/Engine/Native.php on line 199
PHP Stack trace:
PHP   1. {main}() /var/www/util/compute_metrics.php:0
PHP   2. Horde_Text_Diff->__construct() /var/www/util/compute_metrics.php:198
PHP   3. Horde_Text_Diff_Engine_Native->diff() 
/usr/share/pear/Horde/Text/Diff.php:47
PHP   4. Horde_Text_Diff_Engine_Native->_compareseq() 
/usr/share/pear/Horde/Text/Diff/Engine/Native.php:86
PHP   5. Horde_Text_Diff_Engine_Native->_diag() 
/usr/share/pear/Horde/Text/Diff/Engine/Native.php:283
PHP   6. assert() /usr/share/pear/Horde/Text/Diff/Engine/Native.php:199

2018-02-13 17:43:42 cpigott (at) rapitasystems (dot) com Comment #3 Reply to this comment
Can you provide a test case that reproduces this behavior?
I'm still seeing a lot of this in my logs, but my attempts to produce 
a minimal test case have failed so far. However, it seems to be 
related to multiple diff "blocks", and having a change in combination 
with an addition.

I'll keep trying to get an actual example...
2018-01-22 16:21:25 Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
Can you provide a test case that reproduces this behavior?
2017-11-24 11:19:16 cpigott (at) rapitasystems (dot) com Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Summary ⇒ Failed asserts in Text_Diff in 'native' engine
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
Reply to this comment
So I just upgraded to Horde_Text_Diff 2.2.0, but the native engine is 
spewing out warnings about failed asserts:

PHP Warning:  assert(): assert($y <= $this->seq[$k]) failed in 
<snip>/Horde/Text/Diff/Engine/Native.php on line 199
PHP Warning:  assert(): assert($ypos != $this->seq[$end]) failed in 
<snip>/Horde/Text/Diff/Engine/Native.php on line 239

Some searching brought up a WordPress bug report [1] where they 
backported commit 65f92a [2] and noticed the same issue. They didn't 
really come up with a proper fix themselves - just "reverting" to 
using current() and next() instead of each(). That doesn't seem like a 
proper solution to me - it's still relying on mashing the internal 
array pointer that was why each() was deprecated in the first place, 
but regardless it does the job.

In my searching I also found #4497 [3], which seems like it could be 
related to this issue, despite it being a decade old

[1] https://core.trac.wordpress.org/ticket/41526
[2] 
https://github.com/horde/Text_Diff/commit/65f92a945f3745be2953d2bcc24735e860cf70a7
[3] https://bugs.horde.org/ticket/4997

Saved Queries