martoreto / opuscodec

Opus Audio Codec for Android
90 stars 42 forks source link

Crash on x86 emulator #3

Open msalikhov opened 6 years ago

msalikhov commented 6 years ago

Got a crash when trying to init encoder on x86 emulator: 04-16 05:49:12.448 20393-20393/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.018/4662058:userdebug/dev-keys' Revision: '0' ABI: 'x86' pid: 20319, tid: 20319, name: >>> <<< signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0xcfe16825 eax cfe65c18 ebx cfe65c18 ecx cd6ab514 edx 00000070 esi 00000003 edi cd6ab514 xcs 00000023 xds 0000002b xes 0000002b xfs 0000006b xss 0000002b eip cfe16825 ebp ffe4a518 esp ffe4a518 flags 00010296 04-16 05:49:12.449 20393-20393/? A/DEBUG: backtrace:

00 pc 00011825 /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/lib/x86/libsenz.so (silk_VAD_Init+21)

    #01 pc 00015d6a  /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/lib/x86/libsenz.so (silk_init_encoder+106)
    #02 pc 000096a9  /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/lib/x86/libsenz.so (silk_InitEncoder+57)

04-16 05:49:12.450 20393-20393/? A/DEBUG: #03 pc 00043b64 /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/lib/x86/libsenz.so (opus_encoder_init+340)

04 pc 0005251f /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/lib/x86/libsenz.so (Java_com_score_rahasak_utils_OpusEncoder_nativeInitEncoder+63)

    #05 pc 0001e6e8  /data/app/***-O5Bd1zQWVx2i8Lx1uydXsg==/oat/x86/base.odex (offset 0x1e000)
    #06 pc 000d8fff  [anon:libc_malloc:e9000000]
    #07 pc 0000bb7f  <unknown>
LugaMuga commented 6 years ago

Try to disable SSE4_1 for x86. Because not all processors support it.

Rmaan commented 6 years ago
04-25 07:33:41.109 6728-6728/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-25 07:33:41.109 6728-6728/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.007/4586646:user/release-keys'
04-25 07:33:41.109 6728-6728/? A/DEBUG: Revision: '0'
04-25 07:33:41.109 6728-6728/? A/DEBUG: ABI: 'x86'
04-25 07:33:41.109 6728-6728/? A/DEBUG: pid: 6695, tid: 6722, name: Thread-2  >>> me.aarmaan.qq.debug <<<
04-25 07:33:41.109 6728-6728/? A/DEBUG: signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0x83bdb71c
04-25 07:33:41.109 6728-6728/? A/DEBUG:     eax 00000001  ebx 83bfac14  ecx 00000001  edx 838fd793
04-25 07:33:41.109 6728-6728/? A/DEBUG:     esi a73701e4  edi 82c7d000
04-25 07:33:41.110 6728-6728/? A/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
04-25 07:33:41.111 6728-6728/? A/DEBUG:     eip 83bdb71c  ebp 838fd818  esp 838fd73c  flags 00210286
04-25 07:33:41.112 6728-6728/? A/DEBUG: backtrace:
04-25 07:33:41.112 6728-6728/? A/DEBUG:     #00 pc 0004171c  /data/app/me.aarmaan.qq.debug-tSgiQJC6xEQTrgtyH_xsMw==/lib/x86/libsenz.so (opus_packet_parse_impl+1244)
04-25 07:33:41.113 6728-6728/? A/DEBUG:     #01 pc 000435b0  /data/app/me.aarmaan.qq.debug-tSgiQJC6xEQTrgtyH_xsMw==/lib/x86/libsenz.so (opus_decode+272)
04-25 07:33:41.113 6728-6728/? A/DEBUG:     #02 pc 00052c16  /data/app/me.aarmaan.qq.debug-tSgiQJC6xEQTrgtyH_xsMw==/lib/x86/libsenz.so (Java_com_score_rahasak_utils_OpusDecoder_nativeDecodeBytes+182)
04-25 07:33:41.113 6728-6728/? A/DEBUG:     #03 pc 000020d0  /data/app/me.aarmaan.qq.debug-tSgiQJC6xEQTrgtyH_xsMw==/oat/x86/base.odex (offset 0x2000)
04-25 07:33:41.113 6728-6728/? A/DEBUG:     #04 pc 0003a5ff  [anon:libc_malloc:a3600000]
04-25 07:33:41.113 6728-6728/? A/DEBUG:     #05 pc 02c4ce67  /dev/ashmem/dalvik-main space (region space) (deleted)

I got SIGILL when running on x86 emulator. My workaround was disabling on x86 SSE4.1 although my CPU has SSE4.1 and 4.2.

Here is the modified part of my Android.mk

ifeq ($(TARGET_ARCH_ABI),x86)
    LOCAL_CFLAGS += \
                    -DOPUS_X86_MAY_HAVE_SSE -DOPUS_X86_PRESUME_SSE \
                    -DOPUS_X86_MAY_HAVE_SSE2 -DOPUS_X86_PRESUME_SSE2 \
                    #-DOPUS_X86_MAY_HAVE_SSE4_1 -DOPUS_X86_PRESUME_SSE4_1 -msse4.2 \
                    -DOPUS_X86_MAY_HAVE_AVX -mavx \
                    -DOPUS_HAVE_RTCD -DCPU_INFO_BY_C
    HAVE_SSE=1
    HAVE_SSE2=1
    #HAVE_SSE4_1=1
endif

ifeq ($(TARGET_ARCH_ABI),x86_64)
    LOCAL_CFLAGS += \
                    -DOPUS_X86_MAY_HAVE_SSE -DOPUS_X86_PRESUME_SSE \
                    -DOPUS_X86_MAY_HAVE_SSE2 -DOPUS_X86_PRESUME_SSE2 \
                    #-DOPUS_X86_MAY_HAVE_SSE4_1 -DOPUS_X86_PRESUME_SSE4_1 -msse4.2 \
                    -DOPUS_X86_MAY_HAVE_AVX -mavx \
                    -DOPUS_HAVE_RTCD -DCPU_INFO_BY_C
    HAVE_SSE=1
    HAVE_SSE2=1
    #HAVE_SSE4_1=1
endif
msalikhov commented 6 years ago

could you make a pr with updated *.so libs?

Rmaan commented 6 years ago

There is no *.so file in the repo. Here is compiled library with SSE4.1 disabled for x86. You should remove .zip extension (Github doesn't support .aar extension). You could find .so files inside.

opuscodec.aar.zip