carlhuth / google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch
Apache License 2.0
0 stars 0 forks source link

BAD_ACCESS error in Objective-C when Diff_Timeout == 0 or > 6 #64

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Iterate thru a list of text files to compare and prepare diff ranges

2. For each file diff are obtained as below:
DiffMatchPatch* dmp = [DiffMatchPatch new];
dmp.Diff_TimeOut = 0;
NSMutableArray* diffs = [dmp diff_mainOfOldString:oldContent 
andNewString:newContent];
// [dmp diff_cleanupEfficiency:diffs]; 

3.  Sufficiently (around 214,000 chars, 34,00 words in 706 lines) large text 
file with changes to last more than 6 seconds

What is the expected output? What do you see instead?
Expected: around 126 diffs
Actual:
BAD_ACCESS error @ DiffMatchPatch.m
diff_bisectOfOldString:andNewString:deadline:
line:677
676:  for (CFIndex x = 0; x < v_length; x++) {
677:    v1[x] = -1;
678:    v2[x] = -1;
679:  }

What version of the product are you using? On what operating system?
Product Version:diff_match_patch_20120106 (and also in the previous one)
OS: Mac OS X 10.7.2, 64 bit, XCode 4.2, iMac 23"

Please provide any additional information below.
- This happens only when iterating over a list of files (around 300)
- When the problem file in run individually, NO error
- Also works fine in Java
- Diff_TimeOut < 6, works with multi file iteration, but produces coarse diff 
ranges. We need finer ranges and hence Diff_Timeout is set to zero.
- My $0.02 ==> Seems an issue if the 
DiffMatchPatch.diff_bisectOfOldString:andNewString:deadline: is recursed more 
than 5 times

Original issue reported on code.google.com by ampras...@gmail.com on 4 Feb 2012 at 9:16

GoogleCodeExporter commented 8 years ago
And oh.. we tried with referencing:
- non-ARC binary (only build change done was 'Base SDK' set to 'Latest Mac OS X 
(Mac OS X 10.7)')
- ARC converted source and binary (structs convertion tried with both 
'__bridge()' and '__bride_retained()')

Original comment by ampras...@gmail.com on 4 Feb 2012 at 9:55

GoogleCodeExporter commented 8 years ago
Got a crude fix:
After commenting out the following line, seems to work fine!

DiffMatchPatch.diff_lineModeFromOldString:andNewString:deadline:

581:  // Eliminate freak matches (e.g. blank lines)
582:   [self diff_cleanupSemantic:diffs];

--
Anyway we are cleaning up for semantics finally, so guess this might only be a 
performance hit.

Original comment by ampras...@gmail.com on 4 Feb 2012 at 11:52