antimatter15 / tesseract-rs

Rust bindings for Tesseract
MIT License
141 stars 31 forks source link

(signal: 11, SIGSEGV: invalid memory reference) #34

Open olalonde opened 1 year ago

olalonde commented 1 year ago

Fails with (signal: 11, SIGSEGV: invalid memory reference) when both Options are None on ::new().

    let mut tesseract = Tesseract::new(None, None)?
ccouzens commented 1 year ago

Hey, I tried this out in a test

b6b11b1f8ba92df7692419c38f0ed038bc27e07d

and it works fine for me.

Can you tell me more about your setup?

olalonde commented 1 year ago

I'm on MacOs M1, installed tesseract with brew install tesseract. I wasn't able to run the test unfortunately.

~/code/tesseract-rs$ tesseract --version                                                                                                               b6b11b1
tesseract 5.3.0
 leptonica-1.82.0
  libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 2.1.3) : libpng 1.6.39 : libtiff 4.4.0 : zlib 1.2.11 : libwebp 1.3.0 : libopenjp2 2.5.0
 Found NEON
 Found libcurl/7.79.1 SecureTransport (LibreSSL/3.3.5) zlib/1.2.11 nghttp2/1.45.1
~/code/tesseract-rs0 cargo test                                                                                                                        b6b11b1
   Compiling leptonica-plumbing v1.0.0
error[E0277]: `?` couldn't convert the error to `PixReadMemError`
  --> /Users/redacted/.cargo/registry/src/github.com-1ecc6299db9ec823/leptonica-plumbing-1.0.0/src/pix.rs:68:73
   |
68 |         let ptr = unsafe { pixReadMem(img.as_ptr(), img.len().try_into()?) };
   |                                                                         ^ the trait `From<Infallible>` is not implemented for `PixReadMemError`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the trait `From<TryFromIntError>` is implemented for `PixReadMemError`
   = note: required for `Result<RefCountedExclusive<pix::Pix>, PixReadMemError>` to implement `FromResidual<Result<Infallible, Infallible>>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `leptonica-plumbing` due to previous error
ccouzens commented 1 year ago

I also started seeing this 2nd error occasionally. That particular one should be fixed now.

https://github.com/ccouzens/leptonica-plumbing/pull/7

olalonde commented 1 year ago

Strangely, the test passes on my machine as well. Maybe it's some kind of heisenbug or a bug in the tesseract library itself. I'll let you know if I find a way to reproduce it.

olalonde commented 1 year ago

I found out that it fails at the recognize() step.

    let mut tesseract = Tesseract::new(None, None)?
        .set_image_from_mem(&png_bytes)?;
    tesseract = tesseract
        .recognize()?;
ccouzens commented 1 year ago

I've reproduced the issue.