Projects issues random Segmentation fault (core dumped)
Running in gdb:
Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:513
513 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
It's unclear if the fault occurs when you run your program or when building your program. Please also indicate if you're building the release version or the debug version.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d018d2 in tesseract::StringParam::StringParam(char const*, char const*, char const*, bool, tesseract::ParamsVectors*) ()
from /usr/lib/x86_64-linux-gnu/libtesseract.so.5
There will be another error with tensorflow.
I guess than opencv breaks tesseract and tensorflow (may be some dependencies?)
(gdb) bt #0 0x00007ffff7d018d2 in tesseract::StringParam::StringParam(char const*, char const*, char const*, bool, tesseract::ParamsVectors*) ()
at /usr/lib/x86_64-linux-gnu/libtesseract.so.5 #1 0x00007ffff47d0ed0 in () at /usr/lib/x86_64-linux-gnu/libtesseract.so.4 #2 0x00007ffff7fe1fe2 in call_init (l=, argc=argc@entry=1, argv=argv@entry=0x7fffffffec78, env=env@entry=0x7fffffffec88) at dl-init.c:72 #3 0x00007ffff7fe20e9 in call_init (env=0x7fffffffec88, argv=0x7fffffffec78, argc=1, l=) at dl-init.c:30 #4 _dl_init (main_map=0x7ffff7ffe180, argc=1, argv=0x7fffffffec78, env=0x7fffffffec88) at dl-init.c:119 #5 0x00007ffff7fd30ca in _dl_start_user () at /lib64/ld-linux-x86-64.so.2 #6 0x0000000000000001 in () #7 0x00007fffffffee79 in () #8 0x0000000000000000 in ()
(gdb)
This is happening before the Rust main fn is being called right?
I.e. if you put "println!("hello world");" in the rust main fn as first line, nothing shows up?
If that is the case, this looks like some crazy initialization issue between tesseract / whatever else, since it's happening before Rust code is even called ?
Given the crash is happening before the Rust code is even executing, the tesseract forums may be able to help you more than the Rust forums; this seems to require knowledge of tesseract internals.
Based on the backtraces and symptoms we've seen so far, it sounds like tesseract has set up some code to be executed before main (see the ctor crate or __attribute__((constructor)) in C or a static variable with a non-trivial constructor in C++) and it's running into a segfault, probably because something it depends on hasn't been initialized yet.
This can sometimes happen when one static variable is constructed using another static variable, maybe something like this:
One would assume that greeting will be initialized before greetingParam because that's the order that makes sense, but the C++ standard says the order static variables are initialized in is undefined. What this means we might try to construct greetingParam before greeting has been initialized, and then have a bad time when we read an uninitialized variable.
Either way, because there is no Rust code on the stack when the segfault is triggered, this is probably a bug in tesseract and your setup just happens to expose it. I'd create a ticket upstream and see if they can reproduce the issue.
when I add line "use opencv::{self as cv, prelude::*};", program stops working,
in GDB i see another error:
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7478a53 in google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*) () from /usr/lib/libtensorflow_framework.so.2
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7478a53 in google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*) () from /usr/lib/libtensorflow_framework.so.2
(gdb) bt
#0 0x00007ffff7478a53 in google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*) () at /usr/lib/libtensorflow_framework.so.2
#1 0x00007ffff7fe1fe2 in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffec78, env=env@entry=0x7fffffffec88) at dl-init.c:72
#2 0x00007ffff7fe20e9 in call_init (env=0x7fffffffec88, argv=0x7fffffffec78, argc=1, l=<optimized out>) at dl-init.c:30
#3 _dl_init (main_map=0x7ffff7ffe180, argc=1, argv=0x7fffffffec78, env=0x7fffffffec88) at dl-init.c:119
#4 0x00007ffff7fd30ca in _dl_start_user () at /lib64/ld-linux-x86-64.so.2
#5 0x0000000000000001 in ()
#6 0x00007fffffffee7e in ()
#7 0x0000000000000000 in ()
Which project should I build with debug info?
ibtensorflow_framework.so.2 is build using cargo, see
It should contain debug info probably
May be google::protobuf shold be build with debug info?
But error in random, in different combintaions it differs
Yeah this is also a Static Initialization Order Fiasco issue. Upstream issues "your dynamic library breaks _start when it's linked into Rust" seem appropriate.
Another possibility is delayed manual loading of the dynamic libraries: on Unix, dlopen() from main, should give more deterministic ordering.