Skip to content

OpenCV 4.0.1 Crashes on armv7 #14281

Closed
Closed

Description

@YuraIU02
System information (version)
  • OpenCV => 4.0.1:
  • Operating System / Platform => Android 8.0 armeabi-v7a:
  • Compiler => ❔ clang NDK 19, 18, 17, 16
Detailed description

I am trying to use opencv-4.0.1-android-sdk.zip in latest Android studio. For Armv8 everything is ok. Armv7 crashes when I am trying to call compute function.

Maybe I need any special arguments in build.gradle file with Armv7 build?

I tried NDK 19, 18, 17, 16, and "-DANDROID_STL=c++_shared" flags, it does not helps.

Here is Logcat:

signal 7 (SIGBUS), code 1 (BUS_ADRALN)
...
/lib/arm/libopencv_java4.so (_ZN2cv3hal11sepFilter2DEiiiPhjS1_jiiiiiiS1_iS1_iiidi+474)
/lib/arm/libopencv_java4.so (_ZN2cv11sepFilter2DERKNS_11_InputArrayERKNS_12_OutputArrayEiS2_S2_NS_6Point_IiEEdi+428)
/lib/arm/libopencv_java4.so (_ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+432)
/lib/arm/libopencv_java4.so
/lib/arm/libopencv_java4.so (_ZN2cv9Feature2D7computeERKNS_11_InputArrayERNSt6__ndk16vectorINS_8KeyPointENS4_9allocatorIS6_EEEERKNS_12_OutputArrayE+76)
...

Steps to reproduce

call Feature2D.compute or cv::buildOpticalFlowPyramid

Activity

  1. alalek commented on Apr 8, 2019

    @alalek
    Member

    probably relates #12961

  2. alalek commented on Apr 9, 2019

    @alalek
    Member

    Could you try the latest release: OpenCV 4.1.0 ?

  3. Palladinium commented on Jun 4, 2019

    @Palladinium

    I'm having the same issue with armv7 devices, but inside GaussianBlur.
    Unlike @YuraIU02, I'm building my own .so which links to the static prebuilt binaries.
    Updating to 4.1.0 did not help.

    Here are stack trace excerpts from versions running both 4.0.1 and 4.1.0:

    stacktrace_4.0.1.txt
    stacktrace_4.1.0.txt

  4. Palladinium commented on Jun 27, 2019

    @Palladinium

    The fix for #14265 worked for me, but I'm now experiencing a different issue (#14906).

  5. Palladinium commented on Jul 4, 2019

    @Palladinium

    As it turns out, the fix for #14265 did not work, and #14906 was only masking this crash.

    The crash doesn't occur when NEON is disabled (by removing with NEON from the config), and running ndk-stack gives me this:

    ********** Crash dump: **********
    Build fingerprint: 'samsung/j5y17ltedx/j5y17ltedx:7.0/NRD90M/J530YDXU3ARD1:user/release-keys'
    #00 0x0010c776 /data/app/co.myapp.debug-1/lib/arm/libmylib.so
    cv::hal_baseline::v_cvt_f32(cv::hal_baseline::v_int32x4 const&)
    /home/patrick/build/opencv/build/o4a/../../modules/core/include/opencv2/core/hal/intrin_neon.hpp:1554:24
    cv::cpu_baseline::SymmColumnVec_32s8u::operator()(unsigned char const**, unsigned char*, int) const
    /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.simd.hpp:1035:0
    #01 0x0010bc05 /data/app/co.myapp.debug-1/lib/arm/libmylib.so
    cv::cpu_baseline::SymmColumnFilter<cv::cpu_baseline::FixedPtCastEx<int, unsigned char>, cv::cpu_baseline::SymmColumnVec_32s8u>::operator()(unsigned char const**, unsigned char*, int, int, int)
    /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.simd.hpp:2654:21
    #02 0x000fe7bf /data/app/co.myapp.debug-1/lib/arm/libmylib.so
    cv::cpu_baseline::FilterEngine__proceed(cv::FilterEngine&, unsigned char const*, int, int, unsigned char*, int)
    /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.simd.hpp:224:30
    #03 0x000feb17 /data/app/co.myapp.debug-1/lib/arm/libmylib.so
    cv::cpu_baseline::FilterEngine__proceed(cv::FilterEngine&, unsigned char const*, int, int, unsigned char*, int)
    /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.simd.hpp:295:1
    #04 0x00100ea5 /data/app/co.myapp.debug-1/lib/arm/libmylib.so
    cv::FilterEngine::proceed(unsigned char const*, int, int, unsigned char*, int)
    /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.dispatch.cpp:196:1
    #05 0x00101f85 /data/app/co.myapp.debug-1/lib/arm/libmylib.so (_ZN2cv3hal11sepFilter2DEiiiPhjS1_jiiiiiiS1_iS1_iiidi+296)
                                                                      cv::ocvSepFilter(int, int, int, unsigned char*, unsigned int, unsigned char*, unsigned int, int, int, int, int, int, int, unsigned char*, int, unsigned char*, int, int, int, double, int)
                                                                      /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.dispatch.cpp:1232:9
                                                                      cv::hal::sepFilter2D(int, int, int, unsigned char*, unsigned int, unsigned char*, unsigned int, int, int, int, int, int, int, unsigned char*, int, unsigned char*, int, int, int, double, int)
                                                                      /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.dispatch.cpp:1344:0
    #06 0x001023f9 /data/app/co.myapp.debug-1/lib/arm/libmylib.so (_ZN2cv11sepFilter2DERKNS_11_InputArrayERKNS_12_OutputArrayEiS2_S2_NS_6Point_IiEEdi+428)
                                                                      cv::sepFilter2D(cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, cv::Point_<int>, double, int)
                                                                      /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/filter.dispatch.cpp:1424:60
    #07 0x001562cb /data/app/co.myapp.debug-1/lib/arm/libmylib.so (_ZN2cv12GaussianBlurERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+882)
                                                                      cv::cpu_baseline::(anonymous namespace)::fixedSmoothInvoker<unsigned char, cv::(anonymous namespace)::ufixedpoint16>::fixedSmoothInvoker(unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, int, cv::(anonymous namespace)::ufixedpoint16 const*, int, cv::(anonymous namespace)::ufixedpoint16 const*, int, int)
                                                                      /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/smooth.simd.hpp:0:33
                                                                      cv::cpu_baseline::GaussianBlurFixedPoint(cv::Mat const&, cv::Mat&, unsigned short const*, int, unsigned short const*, int, int)
                                                                      /home/patrick/build/opencv/build/o4a/../../modules/imgproc/src/smooth.simd.hpp:2040:0
    

    Which points at this line:

    return v_float32x4(vcvtq_f32_s32(a.val));

    I'm unfortunately out of my depth here, so I'm not sure what to do to fix it.

  6. alalek commented on Jul 4, 2019

    @alalek
    Member

    Thank you for the detailed stack trace!

    Looks like there are other uchar* => int* unaligned pointers casts:

    *(int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();

    and:

    *(int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcategory: imgprocoptimizationplatform: androidplatform: arm

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions