Ask Your Question
0

SEGFAULT in libnative_camera

asked 2013-09-23 05:16:41 -0600

Eric HUBERT gravatar image

Hello everyone,

I'm having hard times finding the root cause of an issue in my native android app using OpenCV video camera feature. And since the libnative_camera source code is not public (unless I'm making a mistake) It's difficult to understand it.

    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
    ...
    #00  pc 0000effc  /system/lib/libc.so
    #01  pc 00011da3  /system/lib/libc.so (dlfree+1458)
    #02  pc 0000cf13  /system/lib/libc.so (free+10)
    #03  pc 0000b28f  /data/app-lib/com.xxx-1/libnative_camera_r4.2.0.so (std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()+4)
    #04  pc 00040c90  /data/app-lib/com.xxx-1/libplgExtVideo.so (-----)

The weird part is that there absolutely no link in my source code between stack #04 and #03.

Is there any way to get a debug version of the libnative_camera ? about its source code? Does it run some static initialization code? Did someone encounter a similar issue?

thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-09-23 12:28:24 -0600

  1. All libraries for native camera are built from folder modules/androidcamera/camera_wrapper in OpenCV repository. You need Android source tree also. You can find some build instructions here. Manual is out of date, but most of parts are described correctly. I'll try to fix manual in the nearest feature.

  2. Native camera uses some undocumented Android API, that is different on different versions of Android. Also different SoC developers make some changes in camera and image processing logic. I think that most of this fails are caused by this changes. If you fix some of them it will be very valuable contibution to OpenCV project.

edit flag offensive delete link more

Comments

Thank you for your precious help. I see in the build instructions the flag "-DANDROID_USE_STLPORT=ON" . and I'm guessing maybe this can be a good hint. Since my app uses multiple shared libraries (including OpenCV ones) and since It is advised to use a single SHARED version of the STL then...

(see CPLUSPLUS-SUPPORT.html from the NDK.)

I will try to build libnative_camera with the gnustl_shared.so I'm using for everything else and see if it fixes my issue.

Will keep you informed. (since it might be a good idea in opencv build scripts to use the same shared STL)

Eric HUBERT gravatar imageEric HUBERT ( 2013-09-24 04:38:39 -0600 )edit

We cannot use gnustl in native_camera libs, because they are linked against Android system libs, that does not support RTTI and exceptions. All native camera's must be linked with shared stlport library to use the same STL as system libs do. Thank you for your comments about STL I'll check it and add comments here, if something will be found.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-09-26 01:32:27 -0600 )edit

Hello, Actually I did the test myself. recompiled native_camera, opencv and all my libs with gnustl_shared and all my issues disappeared. I also tried with everything using stlport_shared, and also stlport_static. no issues neither.

My original issue was that native_camera was using stlport and I was using gnustl for every others libs. Using 2 different kinds of STL was bad. (I do recompile opencv)

I guess it is mandatory to use stlport when recompiling opencv. My bad if I missed any warning/default config or anything else.

Anyway, thanks a lot for your help!

Eric HUBERT gravatar imageEric HUBERT ( 2013-09-26 02:57:09 -0600 )edit

Do you recompile native_camera.so with GNU STL shared? Does it work after that?

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-09-26 07:14:56 -0600 )edit

Yep. It worked for me. I did not, however, made an exhaustive bach of tests. However, the license of the GNU STL is to restrictive, so now I am using STL PORT shared for everything.

Eric HUBERT gravatar imageEric HUBERT ( 2013-09-27 02:45:31 -0600 )edit

Question Tools

Stats

Asked: 2013-09-23 05:16:41 -0600

Seen: 625 times

Last updated: Sep 23 '13