tess4j icon indicating copy to clipboard operation
tess4j copied to clipboard

TessBaseAPIInit1 calls fail with "Invalid memory access" on Windows 10 with included Tesseract Windows 32-bit DLL

Open cdokolas opened this issue 1 year ago • 5 comments

The problem only exists on Windows 10 (not Windows 11!) when using a 32-bit JRE (even with fully-updated VC runtimes). All operations fail because the necessary TessBaseAPIInit1 call fails with an "Invalid memory access" exception like this:

java.lang.Error: Invalid memory access
        at net.sourceforge.tess4j.TessAPI1.TessBaseAPIInit1(Native Method)
        at net.sourceforge.tess4j.Tesseract1.init(Tesseract1.java:427)
        at net.sourceforge.tess4j.Tesseract1.createDocuments(Tesseract1.java:630)
        at net.sourceforge.tess4j.Tesseract1.createDocuments(Tesseract1.java:613)
        at org.example.Main.test1(Main.java:130)
        at org.example.Main.main(Main.java:54)

...or this:

java.lang.Error: Invalid memory access
        at com.sun.jna.Native.invokeInt(Native Method)
        at com.sun.jna.Function.invoke(Function.java:426)
        at com.sun.jna.Function.invoke(Function.java:361)
        at com.sun.jna.Library$Handler.invoke(Library.java:270)
        at jdk.proxy1/jdk.proxy1.$Proxy0.TessBaseAPIInit1(Unknown Source)
        at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:447)
        at net.sourceforge.tess4j.Tesseract.createDocuments(Tesseract.java:650)
        at net.sourceforge.tess4j.Tesseract.createDocuments(Tesseract.java:633)
        at org.example.Main.test2(Main.java:148)
        at org.example.Main.main(Main.java:55)

The problem is clearly with the build of the 32-bit DLL because we've managed (with some difficulty) to build one that worked fine. It was tested by substituting the one inside the official tess4j-5.8.0.jar.

The issue was verified...

With the following Tess4J versions:

  • 5.8.0
  • 5.10.0

On the following 32-bit JREs:

  • Temurin 17.0.9+9
  • Temurin 19.0.2+7
  • Oracle 1.8.0_202

cdokolas avatar Jan 22 '24 09:01 cdokolas

@cdokolas The library was tested with both Java 8 (1.8.0_401) 32- and 64-bit on Windows 11. The Windows binaries were built using VS2022 with the following settings:

Windows SDK version: 10.0.22000.0 Platform Toolset: Visual Studio 2022 (v143) C++ Language Standard: ISO C++20 Standard (/std:c++20) C Language Standard: Default (Legacy MSVC)

nguyenq avatar Jan 25 '24 02:01 nguyenq

Possible duplicate of Issue #250.

nguyenq avatar Jan 25 '24 05:01 nguyenq

@cdokolas Can you test with the latest version in the repo?

nguyenq avatar Mar 02 '24 19:03 nguyenq

@cdokolas Can you test with the latest version in the repo?

Unfortunately not at the moment. I don't have a Windows 10 system in hand :(

cdokolas avatar Mar 05 '24 14:03 cdokolas

I had the tess4j version in question run successfully on Windows 10 Version 22H2.

The latest Windows binaries are built with:

Windows SDK version: 10.0.22621.0 Platform Toolset: Visual Studio 2022 (v143) C++ Language Standard: ISO C++17 Standard (/std:c++17) C Language Standard: ISO C17 (2018) Standard (/std:c17)

nguyenq avatar Mar 08 '24 04:03 nguyenq

Close the ticket. Unable to reproduce the issue on Windows 10.

nguyenq avatar May 30 '24 07:05 nguyenq