0

I am new to developing a robust software for computer vision in C++.

Due to the confidentiality of the nature of the third-party functions I use, I will try to describe it as completely as possible.

I am trying to compile my source code on a Linux environment. This source code uses many third-party functions and shared objects.

Basically I am trying to combine several APIs provided by the third-party into a single functional executable. All the functions work perfectly fine in its respective API.

=================================================

Long story short, after the successful compilation, I encounter Segmentation Fault as the error during the running of the executable.

After, doing backtrace and debugging with gdb, I found that the program stops at the address 0x0000007b602b5c8 from a shared object (.so) file provided by the third party.

I tried using the command info symbol and info line *0x0000007b602b5c8 to identify the symbol for that address and the variables for the stack frame. However, I receive the error

'No line number information available for address 0x0000007b602b5c8'

and

'No symbol matches 0x0000007b602b5c8'

I tried using info target as well without success.

Any idea how I can solve this segmentation fault error?

Paul T.
  • 4,703
  • 11
  • 25
  • 29

2 Answers2

0

Often (but not always) third party libraries supply a debug version, with line numbers and symbols left visible in shared objects if this is your case you can try to compile linking debug libs instead of release versions.

Otherwise you have to take for granted that third party stuff works and you have to look on your side...

A segmentation fault normally means that you are trying to call a method from an instance that has not been created or that has already been released or that was not initialized properly. So you have to start looking one at a time for all the objects you create and destroy and see you have done any mistakes. (Valgrind can help you with that).

Good luck

Marco
  • 1,952
  • 1
  • 17
  • 23
  • I am pretty sure that initialization is not the problem as I only added several lines of codes (initialization of a different type of camera) from a previous version of a working code.Beyond that, what else can cause segmentation fault? – Joandy Leonata Nov 09 '17 at 08:19
  • One other popular reason for segmentation fault is accessing an array past its boundaries, but your case seems to be strictly connected with an hardware and it is possible that the driver is faulty (programmers who write drivers leave bugs too). – Marco Nov 09 '17 at 09:03
  • I also suggest you have a look at the second answer from this question: https://stackoverflow.com/questions/2346806/what-is-a-segmentation-fault?rq=1 – Marco Nov 09 '17 at 09:08
  • how do I determine the root problem for this particular type of segmentation fault though? It's pretty odd that I am using the exact same function and variables, yet the segmentation fault occured. – Joandy Leonata Nov 09 '17 at 09:08
0

The typical way of having debug information for library files is not an alternative debug version of the library, but an additional file, which maps exactly to the binary you got.

https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

So try to get these debug information for the libs you are using. But this makes only sense, if you also have a minimum of header/source files in place. If not, you only get a symbol but points to nothing. If the source of the lib is not open source, you will be lost at this point.

But you should first think about your own programming problems. Maybe you give wrong pointers, wrong allocated memory, insufficient arrays or whatever to your lib as parameter and the crash comes later in the lib but the problem is in your code.

So you should start with memory debugging libs like efence and others ( maybe newer ones ). Give valgrind a chance!

If all that will not help, create a bug report for the lib and provide there a minimal example which results to the crash.

And before that, you should check if there are newer versions available, which already fixed that bug. Maybe you can check early beta versions or if open source the head of development.

Klaus
  • 24,205
  • 7
  • 58
  • 113