patcharats / tesseract-ocr

Automatically exported from code.google.com/p/tesseract-ocr
Other
0 stars 0 forks source link

Patch needs to be merged into Release 78 to fix ocropus 100% CPU bug #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build & run tesseract on Redhat Enterprise Linux 4.0

What is the expected output? What do you see instead?

Freezes/100% CPU used. This is entirely resolved by applying a patch posted
by another user, see:
http://sourceforge.net/tracker/download.php?group_id=158586&atid=808426&file_id=
215692&aid=1658610

P.S. This is a cross-post from ocropus issues:
http://code.google.com/p/ocropus/issues/detail?id=20&can=2&q=

Original issue reported on code.google.com by fil...@repairfaq.org on 22 Apr 2007 at 11:56

GoogleCodeExporter commented 9 years ago
I apologize - the "Release 78" refers to ocropus, not tesseract. I just checked 
and
Release 31 of tesseract is still 'broken'.

It appears that the version of gcc/g++ on Redhat Enterprise Linux 4.0 optimizes
incorrectly two lines in textord/makerow.cpp such that there is a lock. That 
patch
merely adds an intermediate variable and 'prevents' said optimization 'bug'.

I reproduce the patch here so you can see what is changed:

RCS file: /cvsroot/tesseract-ocr/tesseract/textord/makerow.cpp,v
retrieving revision 1.2
diff -u -r1.2 makerow.cpp
--- textord/makerow.cpp 2 Feb 2007 23:47:06 -0000   1.2
+++ textord/makerow.cpp 13 Feb 2007 05:25:52 -0000
@@ -785,6 +785,7 @@
   INT32 line_index;              //of scan line
   float top, bottom;             //coords of blob
   INT32 width;                   //of blob
+  INT32 idx;
   TO_ROW *row;                   //current row
   TO_ROW_IT row_it = block->get_rows ();
   BLOBNBOX *blob;                //current blob
@@ -816,13 +817,15 @@
           "Bad y coord of bottom, " INT32FORMAT "(" INT32FORMAT ","
           INT32FORMAT ")\n", (INT32) floor (bottom), min_y, max_y);
                                  //count transitions
-      deltas[(INT32) floor (bottom) - min_y] += width;
+      idx = (INT32) floor (bottom) - min_y;
+      deltas[idx] += width;
       if ((INT32) floor (top) < min_y
         || (INT32) floor (top) - min_y >= line_count)
         fprintf (stderr,
           "Bad y coord of top, " INT32FORMAT "(" INT32FORMAT ","
           INT32FORMAT ")\n", (INT32) floor (top), min_y, max_y);
-      deltas[(INT32) floor (top) - min_y] -= width;
+      idx = (INT32) floor (top) - min_y;
+      deltas[idx] -= width;
     }
   }
   occupation[0] = deltas[0];

Original comment by fil...@repairfaq.org on 26 Apr 2007 at 11:51

GoogleCodeExporter commented 9 years ago
BTW, I'm not certain that this defect is Priority-Medium as it a) causes 100% 
CPU use
on all Redhat Enterprise Linux 4.0 platforms unless compiled without 
optimization and
b) is so trivial to completely resolve.

Original comment by fil...@repairfaq.org on 26 Apr 2007 at 11:53

GoogleCodeExporter commented 9 years ago
This is fixed in the subversion repository. Not yet in the tarball.

Original comment by theraysm...@gmail.com on 17 May 2007 at 8:43

GoogleCodeExporter commented 9 years ago

Original comment by theraysm...@gmail.com on 18 Jul 2007 at 10:27