Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when support ArmNN AIDL backend based on a shim over the NNAPI Support Library #770

Open
khuongtrinh2 opened this issue May 9, 2024 · 2 comments
Labels
TIME WAIT Waiting for an approppriate period for a response before closing the issue.

Comments

@khuongtrinh2
Copy link

Hello team,
On v23.02, I was trying to support ArmNN AIDL based on a shim over the NNAPI Support Library.
Step:

  1. In device.mk, add:

PRODUCT_PACKAGES += android.hardware.neuralnetworks-shim-service-armnn

  1. In sepolicy:
  • Create hal_neuralnetworks_armnn.te:
    type hal_neuralnetworks_armnn, domain;
    hal_server_domain(hal_neuralnetworks_armnn, hal_neuralnetworks)
    type hal_neuralnetworks_armnn_exec, exec_type, vendor_file_type, file_type;
    init_daemon_domain(hal_neuralnetworks_armnn)
    add_service(hal_neuralnetworks_armnn, armnn_nnapi_service);

  • Modify service_contexts, add:
    android.hardware.neuralnetworks.IDevice/google-armnn u:object_r:armnn_nnapi_service:s0

  • Modify file_contexts, add:
    /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn u:object_r:hal_neuralnetworks_armnn_exec:s0

After complete these above step, I start hal_neuralnetworks_armnn service and get log crash:

--------- beginning of crash
03-20 04:16:01.148 420 420 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 420 (android.hardwar), pid 420 (android.hardwar)
03-20 04:16:01.865 0 0 I logd : logdr: UID=1000 GID=1000 PID=526 n tail=500 logMask=8 pid=420 start=0ns deadline=0ns
03-20 04:16:01.875 0 0 I logd : logdr: UID=1000 GID=1000 PID=526 n tail=500 logMask=1 pid=420 start=0ns deadline=0ns
03-20 04:16:01.889 526 526 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-20 04:16:01.889 526 526 F DEBUG : Revision: '1.0'
03-20 04:16:01.889 526 526 F DEBUG : ABI: 'arm64'
03-20 04:16:01.889 526 526 F DEBUG : Timestamp: 2024-03-20 04:16:01.652114521+0000
03-20 04:16:01.889 526 526 F DEBUG : Process uptime: 6s
03-20 04:16:01.890 526 526 F DEBUG : Cmdline: /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn -c CpuAcc
03-20 04:16:01.890 526 526 F DEBUG : pid: 420, tid: 420, name: android.hardwar >>> /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn <<<
03-20 04:16:01.890 526 526 F DEBUG : uid: 1000
03-20 04:16:01.890 526 526 F DEBUG : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
03-20 04:16:01.890 526 526 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000020
03-20 04:16:01.890 526 526 F DEBUG : Cause: null pointer dereference
03-20 04:16:01.890 526 526 F DEBUG : x0 b400f6a20c99e1e8 x1 0000f6a2fdc651e0 x2 0000ffffe2b71a80 x3 0000ffffe2b719a8
03-20 04:16:01.890 526 526 F DEBUG : x4 0000000000000060 x5 b400f6a1fc9a9030 x6 3dcccccd00000000 x7 3dcccccd3dcccccd
03-20 04:16:01.890 526 526 F DEBUG : x8 0000000000000000 x9 0000c447fa960940 x10 0000ffffe2b71a88 x11 000000000000000f
03-20 04:16:01.890 526 526 F DEBUG : x12 0000000000006b84 x13 0000000000000001 x14 ffffffffffffffff x15 0000000000000000
03-20 04:16:01.890 526 526 F DEBUG : x16 0000c447faa566d0 x17 0000f6a302880480 x18 0000f6a30877c000 x19 b400f6a20c99e1e8
03-20 04:16:01.890 526 526 F DEBUG : x20 0000ffffe2b71a78 x21 0000f6a30802a000 x22 0000ffffe2b71a78 x23 0000f6a30802a000
03-20 04:16:01.890 526 526 F DEBUG : x24 0000f6a30802a000 x25 0000c447faa500b0 x26 0000c447faa57d78 x27 0000000000000000
03-20 04:16:01.890 526 526 F DEBUG : x28 b400f6a20c99de00 x29 0000ffffe2b719d0
03-20 04:16:01.890 526 526 F DEBUG : lr 0000f6a2fdd42a68 sp 0000ffffe2b719a0 pc 0000f6a2fdc65224 pst 0000000000001000
03-20 04:16:01.890 526 526 F DEBUG : 7 total frames
03-20 04:16:01.890 526 526 F DEBUG : backtrace:
03-20 04:16:01.890 526 526 F DEBUG : #00 pc 0000000001235224 /vendor/lib64/libarmnn_support_library_prebuilt.so (armnn_driver::ArmnnDriver::getNumberOfCacheFilesNeeded() const+68) (BuildId: 7227e80cac6f024da9bd3555a4c61b64)
03-20 04:16:01.890 526 526 F DEBUG : #1 pc 0000000001312a64 /vendor/lib64/libarmnn_support_library_prebuilt.so (SL_ANeuralNetworksDevice_getNumberOfCacheFilesNeeded+72) (BuildId: 7227e80cac6f024da9bd3555a4c61b64)
03-20 04:16:01.890 526 526 F DEBUG : #2 pc 0000000000070028 /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn (aidl::android::hardware::neuralnetworks::ShimDevice::ShimDevice(std::__1::shared_ptr, ANeuralNetworksDevice*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >)+696) (BuildId: 2a5ff4e20e796027757aae11d3a172b5)
03-20 04:16:01.890 526 526 F DEBUG : #3 pc 000000000006e878 /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn (std::__1::shared_ptraidl::android::hardware::neuralnetworks::ShimDevice ndk::SharedRefBase::make<aidl::android::hardware::neuralnetworks::ShimDevice, std::__1::shared_ptr&, ANeuralNetworksDevice*&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&>(std::__1::shared_ptr&, ANeuralNetworksDevice*&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)+120) (BuildId: 2a5ff4e20e796027757aae11d3a172b5)
03-20 04:16:01.890 526 526 F DEBUG : #4 pc 000000000006dadc /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn (android::neuralnetworks::shim::registerDevices(NnApiSLDriverImpl*, std::__1::vector<android::neuralnetworks::shim::ShimDeviceInfo, std::__1::allocatorandroid::neuralnetworks::shim::ShimDeviceInfo > const&, unsigned int, bool, bool)+1596) (BuildId: 2a5ff4e20e796027757aae11d3a172b5)
03-20 04:16:01.891 526 526 F DEBUG : #5 pc 000000000006c0f4 /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn (main+148) (BuildId: 2a5ff4e20e796027757aae11d3a172b5)
03-20 04:16:01.917 526 526 F DEBUG : #6 pc 00000000000546e8 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+104) (BuildId: 19c32900d9d702c303d2b4164fbba76c)

I run /vendor/bin/hw/android.hardware.neuralnetworks-shim-service-armnn and see that my device doesn't have OpenCL library (No support yet)

Can't load libOpenCL.so: dlopen failed: library "libOpenCL.so" not found
Can't load libGLES_mali.so: dlopen failed: library "libGLES_mali.so" not found
Can't load libmali.so: dlopen failed: library "libmali.so" not found
Can't load libOpenCL-pixel.so: dlopen failed: library "libOpenCL-pixel.so" not found
Can't load libOpenCL-car.so: dlopen failed: library "libOpenCL-car.so" not found
Couldn't find any OpenCL library.

After, I try disable OpenCL (set opencl =0, embed_kernels=0 in Compute Library and -DARMCOMPUTECL=0 in Arm NN before build) but it still crashes.

Anyone helps me with this issue, Thank you so much.

@Colm-in-Arm
Copy link
Collaborator

Hi khuongtrinh2,

This is not a configuration we've ever tried and I'm not too familiar with our shim/support library configuration. Looking at the stack trace the seg fault appears to be happening when that code attempts to address a backendin canonical/ArmnnDriver.hpp. What are you setting for ARMNN_SL_OPTIONS environment variable?

Colm.

@khuongtrinh2
Copy link
Author

Hi Colm-in-Arm
Thank you for your support,
Can you share some configuration you've ever tried? Thank you so much.
I set ARMNN_SL_OPTIONS=-c CpuAcc

@Colm-in-Arm Colm-in-Arm added the TIME WAIT Waiting for an approppriate period for a response before closing the issue. label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TIME WAIT Waiting for an approppriate period for a response before closing the issue.
Projects
None yet
Development

No branches or pull requests

2 participants