Skip to content
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

JVM crashes on CentOS 6.5 since 1.4.2 (Tesseract 4.0) #680

Closed
seanliang opened this issue Jan 30, 2019 · 6 comments
Closed

JVM crashes on CentOS 6.5 since 1.4.2 (Tesseract 4.0) #680

seanliang opened this issue Jan 30, 2019 · 6 comments
Labels

Comments

@seanliang
Copy link

My program works well on Windows, but always crashes on CentOS 6.5.

The content of Test.java:

import org.bytedeco.javacpp.BytePointer;

import static org.bytedeco.javacpp.lept.*;
import static org.bytedeco.javacpp.tesseract.TessBaseAPI;

public class Test {
    public static void main(String[] args) {
        TessBaseAPI api = new TessBaseAPI();
        if (api.Init("/data/tessdata", "eng") != 0) {
            throw new RuntimeException("Tesseract init failed");
        }
        PIX image = pixRead("/data/test.jpg");
        api.SetImage(image);
        BytePointer outText = api.GetUTF8Text();
        String captchaInString = outText.getString();
        System.out.println("Output: " + captchaInString);
        api.End();
        outText.deallocate();
        pixDestroy(image);
        api.close();
    }
}

The build.gradle file:

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'java'

ext {
    ver = '1.4.4'
    if (Os.isFamily(Os.FAMILY_UNIX)) {
        os = 'linux'
    }
    if (Os.isFamily(Os.FAMILY_MAC)) {
        os = 'macosx'
    }
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        os = 'windows'
    }
    arch = System.getProperty("os.arch");
    if (arch == 'amd64') {
        arch = 'x86_64'
    }
    platform = os + '-' + arch;
}

group 'com.test'
version '1.0'

sourceCompatibility = 1.7

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.bytedeco', name: 'javacv', version: ver
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: ver, classifier: platform
    compile group: 'org.bytedeco.javacpp-presets', name: 'tesseract', version: ver, classifier: platform
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: ver, classifier: platform
}

The error output:

libpng error: bad parameters to zlib
Error in pixReadMemPng: internal png error
Error in pixReadMem: png: no pix returned
src_pix != nullptr:Error:Assert failed:in file imagedata.cpp, line 233
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f5ba62c614a, pid=76886, tid=140031907813120
#
# JRE version: OpenJDK Runtime Environment (7.0_181) (build 1.7.0_181-mockbuild_2018_05_01_18_00-b00)
# Java VM: OpenJDK 64-Bit Server VM (24.181-b00 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 2.6.14
# Distribution: CentOS release 6.9 (Final), package rhel-2.6.14.1.el6_9-x86_64 u181-b00
# Problematic frame:
# C  [libtesseract.so.4+0x26814a]  ERRCODE::error(char const*, TessErrorLogCode, char const*, ...) const+0x12a
#

If I switch the version to 1.4 (Tesseract 3.05), the problem is gone.

Any idea? Thanks.

@saudet
Copy link
Member

saudet commented Jan 30, 2019

compile group: 'org.bytedeco.javacpp-presets', name: 'tesseract', version: ver, classifier: platform

That's not a version that exists. Please correct your build file.

@seanliang
Copy link
Author

The tesseract module was added to dependencies part of javacv POM file since 1.4.2, gradle will use that sepecific version by default.

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.bytedeco:javacv:1.4.4
|    +--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:ffmpeg:4.1-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:flycapture:2.13.3.31-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:libdc1394:2.2.5-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:libfreenect:0.5.3-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:libfreenect2:0.2.0-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:librealsense:1.12.1-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:videoinput:0.200-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:artoolkitplus:2.3.1-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:flandmark:1.07-1.4.4
|    |    +--- org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4 (*)
|    |    \--- org.bytedeco:javacpp:1.4.4
|    +--- org.bytedeco.javacpp-presets:leptonica:1.77.0-1.4.4
|    |    \--- org.bytedeco:javacpp:1.4.4
|    \--- org.bytedeco.javacpp-presets:tesseract:4.0.0-1.4.4
|         +--- org.bytedeco.javacpp-presets:leptonica:1.77.0-1.4.4 (*)
|         \--- org.bytedeco:javacpp:1.4.4
+--- org.bytedeco.javacpp-presets:opencv:1.4.4 -> 4.0.1-1.4.4 (*)
+--- org.bytedeco.javacpp-presets:tesseract:1.4.4 -> 4.0.0-1.4.4 (*)
\--- org.bytedeco.javacpp-presets:leptonica:1.4.4 -> 1.77.0-1.4.4 (*)

the actual libraries files:

-rw-r--r-- 1    24088 Jan 30 18:09 artoolkitplus-2.3.1-1.4.4.jar
-rw-r--r-- 1   249032 Jan 30 18:09 ffmpeg-4.1-1.4.4.jar
-rw-r--r-- 1    11733 Jan 30 18:09 flandmark-1.07-1.4.4.jar
-rw-r--r-- 1   131039 Jan 30 18:09 flycapture-2.13.3.31-1.4.4.jar
-rw-r--r-- 1   386638 Jan 30 18:09 javacpp-1.4.4.jar
-rw-r--r-- 1   406695 Jan 30 18:09 javacv-1.4.4.jar
-rw-r--r-- 1   156069 Jan 30 18:09 leptonica-1.77.0-1.4.4.jar
-rw-r--r-- 1  2839811 Jan 30 18:09 leptonica-1.77.0-1.4.4-linux-x86_64.jar
-rw-r--r-- 1    30800 Jan 30 18:09 libdc1394-2.2.5-1.4.4.jar
-rw-r--r-- 1    21956 Jan 30 18:09 libfreenect-0.5.3-1.4.4.jar
-rw-r--r-- 1    24708 Jan 30 18:09 libfreenect2-0.2.0-1.4.4.jar
-rw-r--r-- 1    49770 Jan 30 18:09 librealsense-1.12.1-1.4.4.jar
-rw-r--r-- 1  1516552 Jan 30 18:09 opencv-4.0.1-1.4.4.jar
-rw-r--r-- 1 19319284 Jan 30 18:09 opencv-4.0.1-1.4.4-linux-x86_64.jar
-rw-r--r-- 1    73751 Jan 30 18:09 tesseract-4.0.0-1.4.4.jar
-rw-r--r-- 1  1678596 Jan 30 18:09 tesseract-4.0.0-1.4.4-linux-x86_64.jar
-rw-r--r-- 1    17032 Jan 30 18:09 videoinput-0.200-1.4.4.jar

@saudet saudet added the bug label Jan 31, 2019
@saudet
Copy link
Member

saudet commented Jan 31, 2019

This is odd, it works with 1.5.30, but not with any of the 1.6.x series. I've checked everything else, the only variable seems to be CentOS 6 itself, and maybe something that changed between JavaCPP 1.3 and 1.4 (it doesn't work with 1.74.4-1.4 for me). Well, let's downgrade to 1.5.30 and see how well that works.

@seanliang
Copy link
Author

Yes. I test it under Ubuntu and CentOS 7, and it works as expected.

@saudet
Copy link
Member

saudet commented Feb 1, 2019

Please give it a try with 1.4.5-SNAPSHOT: http://bytedeco.org/builds/ Thanks!

@saudet
Copy link
Member

saudet commented Apr 11, 2019

The downgrade has been included in version 1.5. Thanks for reporting!

@saudet saudet closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants