-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC optimization /Ot (included in /O2) breaks tesseract release build #1223
Comments
How did you build tesseract? |
As I made some progress I updated the issue to better describe what is happening. |
I would suggest you make sure that the all dependencies (at least leptonica) are build as 64bit and with the same version of compiler... |
It is a 64 bit version of leptonica - otherwise it would not work at all. |
Hi, Not sure if this is your post https://groups.google.com/forum/#!topic/tesseract-ocr/lufafrAAEnk Did you try |
Not my post and it does not look like the problem has anything to do with /Ob2. |
Found similar problem in ColPartitionGrid::ComputeTotalOverlap with some input files. |
@MarkusGH, did you also restore optimization after |
Yes - I put #pragma optimize( "", on ) directly after the functions. |
To check if this is VS2017 issue, it's necessary to build on VS2015. |
I think it is too early to blame MSVC for this issue. As you use gcc I would kindly suggest to create a build with the gcc option -ftrapv (and maybe other options necessary to bring the debugger to break on integer overflows) and try the test case I provided to see if it actuall produces integer overflows. If so this makes a case to investigate further in that direction. |
A Tesseract executable which was compiled with |
Oh - so it looks like the integer overflow hypothesis is dead. |
I tested the latest binary from AppVeyor. It shows the same problem when running It looks like |
@egorpugin, I tried a local build on Windows 7 to debug the problem, but failed: cppan.exe crashed very often with SIGSEGV, and when it finally passed, I got a cmake failure similar to https://github.com/cppan/cppan/issues/36. Is there an alternative way to build Tesseract with VS 2017 community edition? |
Could you try the latest build? |
@stweil I have the same issue here with Thanks @egorpugin i will try that Edit: not working... i will try overiding |
@egorpugin okay i will try this tkx. Have you read my edited comment on cppan/cppan#36 ? I have added my fix for this issue as well FIX |
New client is a possible fix for your issue too. Try it. |
Even with the latest |
Are you trying this on windows? |
Sure. I tried it on Windows 7 / 64 bit from the Visual Studio command line. |
Maybe this one? |
I got messages about crash dumps (minidumps), but did not find the dump files. I'll have a look at the indicated location later. |
The |
Debug version: |
@MarkusGH @stweil @FaisalHussain95 Is this issue solved? |
I just repeated the previous test with the latest binary, and it looks like the issue is fixed. |
@zdenop Yes it works ! |
Environment
Current Behavior:
Test.zip
Command:
tesseract.exe C:\Test.tif C:\Test -l deu+eng --psm 1 --oem 1 pdf
Error messages:
None
Result:
Correct PDF created, OCR results OK
Command:
tesseract.exe C:\Test.tif C:\Test -l deu+eng --psm 1 --oem 0 pdf
Error messages:
None
Result:
Correct PDF created, OCR results OK
Command:
tesseract.exe C:\Test.tif C:\Test -l deu+eng --psm 1 --oem 1 pdf
Error messages:
Multiple times:
Error in pixCreateHeader: height must be > 0
Error in pixCreateNoInit: pixd not made
Error in pixCreate: pixd not made
Error in pixClipRectangle: pixd not made
Result:
Broken PDF created.
Conclusion:
Release build shows erratic behavior when LSTM is used, errormessages and/or wrong output.
Debug And MinSizeRel builds work slowly but correctly.
As soon as the optimization /Ot is switched to /Os (or from /O2 to /O1) or LSTM is not used all problems go away.
Expected Behavior:
Release build behaves like MinSizeRel/Debug built.
Suggested Fix:
Problem is located in Tesseract::GetRectImage
As soon as speed optimization for this function is switched off with #pragma optimize( "t", off ) the problem goes away.
The text was updated successfully, but these errors were encountered: