6.0.0-alpha10
5/14/25

[#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 11/24/2017 (2728 days ago)
Due
Updated 09/23/2018 (2425 days ago)
Assigned 01/22/2018 (2669 days ago)
Resolved
Milestone
Patch No

History
09/23/2018 07:07:58 PM 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

02/13/2018 05:43:42 PM 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...
01/22/2018 04:21:25 PM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
Can you provide a test case that reproduces this behavior?
11/24/2017 11:19:16 AM cpigott (at) rapitasystems (dot) com Comment #1
Priority ⇒ 2. Medium
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Failed asserts in Text_Diff in 'native' engine
Type ⇒ Bug
State ⇒ Unconfirmed
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