Issue 21494 - The "Find and Replace" Function fails when replacing more than 60000+ strings.
Summary: The "Find and Replace" Function fails when replacing more than 60000+ strings.
Status: CLOSED WONT_FIX
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 1.1 RC5
Hardware: PC Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: jack.warchold
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-21 11:18 UTC by Unknown
Modified: 2010-10-23 15:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2003-10-21 11:18:44 UTC
The Replace function doesn't replace more than ~60000 occurrences of a string. 
However, 60000 is not the boundary. Depending on the size of the both find and 
replace strings, the boundary slightly changes. 

Test 1
Steps of reproduction:
1) Build a file (in a simple word processor such as notepad or MS Word) of 
60001 occurrences of the letter 'a'
2) Copy the 60001 a's into a new OpenOffice Text document.
3) Goto Edit > Find & Replace
4) In the find box type 'a', and in the replace type 'b'
5) Do a "Replace all" and wait until operation finishes.
6) Scroll down to the bottom of the document to check weather all a's been turn 
into b's

In my case, OO reports it did 60000 replaces, and one is 'a' left. When I 
repeated the steps with 60002, 60003, etc, I always got an extra 2, 3, n (if # 
of a's were 60000 + n) while the program always reported only 60000 replaces.
I did a second test where I produced 70000 strings of "This That They" in one 
document, and replaced "This" with "----". Again, I only got 60000 replaces. 
The rest of the document seemed to be unharmed and unchanged.

I ran another test to test the Find and Replace, except that I changed the size 
of the find string to be different from the replace.
Test 1
Steps of reproduction:
1) Build a file (in a simple word processor such as notepad or MS Word) of 1000 
occurrences of the letter 'a'
2) Build another file (in a simple word processor such as notepad or MS Word) 
of 100 occurrences of the letter 'b'
3) Copy the 1000 a's into a new OpenOffice Text document.
4) Goto Edit > Find & Replace
5) In the find box type 'a', and in the replace copy the 100 bs
6) Do a "Replace all" and wait until operation finishes.
7) Check how much replaces OO Does.
8) With a word counting software like MS Word, Count the number of characters 
resultant.

In theory, the count of characters should be 100000. However there are only 
65535 (2^16-1). It also should do 1000 replaces; however, it only does 652. And 
at the bottom are all the as that werent converted.

From the looks of these tests, there seems to be a buffer problem in the find 
or replace function. I conducted 12 more tests. However I obtained more 
inexplicable anomalies that I couldnt mimic again. 
Here are some examples
-	Find: a and Replace with bb on the string aaaaaaaaaaaaaaa, the 
result would be abbabbabbabbabbabbabbabbabba
-	Find: th and Replace with wh on the string This That Them 
(repeated 7000 times), the resultant would be 65535 replacements, and half of 
the document was deleted!

Another interesting anomaly I got is when I finished testing with one document, 
if I tried to do another test on that file, and do a normal replace of a 
with b on aaaaaa, my resultant string would be baaaaa with one replace. 
Again I wasnt able to reproduce these bugs.

Although these cases might be to extreme and never occur with normal users, 
there is a disturbing functionality behind the find and replace. If the 
operation fails randomly with large counts of text, I dont feel as confident 
that for lower counts it will work perfectly. 

Software like MS Word is able to do these operation perfectly flawless and in 
record breaking time. In addition, the find is VERY slow. I used MS Word to 
benchmark the results, and compare. There wasnt a test where Word out 
preformed OOText in the third of the time and did all the possible replaces.

All the test were ran on a
AMD 2200 (+1800mhz)
Windows 2000 Server
512mb DDR Ram
-- and on a 
P4 2400 mhz
Windows XP Professional
1024mb RD RAM @ 1066mhz 

Test cases presented above all behaved the same way on both testing machines.
Comment 1 utomo99 2003-10-28 02:49:49 UTC
Utomo > Proalpha:
Please attach the file, so we can test it faster. 


Change subcomponent to code. 

Comment 2 jack.warchold 2003-11-10 15:54:16 UTC
reassigend to jw
Comment 3 jack.warchold 2003-11-27 14:52:31 UTC
i can not confirm this behavior on OOo final, i followed your 
instructions and always got all characters replaced.
after some time OOo asked me to disable the undo funktion of this F&R 
prozess, if i agree all characters will be replaced, if i do not agree 
only 60000 character will be replaced, this is due an technical issue, 
because memory is always limitted and we have to set a limit for 
undofunctions to be stored, so if you like to F&R more than 60000 
character please just agree the question to disable the undofunction 
for this single F&R process
Comment 4 jack.warchold 2003-11-27 14:54:47 UTC
wontfix -> closed
Comment 5 cuodenumyp 2010-10-23 15:45:15 UTC
Created attachment 72684