Michiel
Michiel

Reputation: 768

RenderScript crashes on Android 5 (API 21) with Fatal signal 6 (SIGABRT)

I've build an app using RenderScript which works fine on most phones, but crashes on initializing on fi. the emulator with API 21. I've minimized my renderscript code to see when it still crashes. It happens on macOS Catalina and on Ubuntu 19.10.

This compiles:

#pragma version(1)
#pragma rs java_package_name(com.me.my-obfuscated_package-name);

rs_allocation myFirstAlloc;

But crashes on the second line:

    private val renderScript = RenderScript.create(context)
    private val scriptTest = ScriptC_test(renderScript)

On this particular line in ScriptC.java:

    /**
     * Only intended for use by the generated derived classes.
     *
     * @param rs
     */
    protected ScriptC(RenderScript rs, String resName, byte[] bitcode32, byte[] bitcode64) {
        super(0, rs);
        long id = 0;
        if (RenderScript.sPointerSize == 4) {
            id = internalStringCreate(rs, resName, bitcode32);
        } else {
            id = internalStringCreate(rs, resName, bitcode64); // <<< Exception thrown here
        }
        if (id == 0) {
            throw new RSRuntimeException("Loading of ScriptC script failed.");
        }
        setID(id);
    }

Logcat

--------- beginning of crash
04-18 14:51:25.656 20905-21024/com.myapp.debug A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 21024 (handshare.debug)
04-18 14:51:25.763 12867-12867/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-18 14:51:25.763 12867-12867/? I/DEBUG: Build fingerprint: 'generic_x86_64/sdk_google_phone_x86_64/generic_x86_64:5.0.2/LSY66K/5523115:eng/test-keys'
04-18 14:51:25.763 12867-12867/? I/DEBUG: Revision: '0'
04-18 14:51:25.763 12867-12867/? I/DEBUG: ABI: 'x86_64'
04-18 14:51:25.764 12867-12867/? I/DEBUG: pid: 20905, tid: 21024, name: handshare.debug  >>> com.myapp.debug <<<
04-18 14:51:25.764 12867-12867/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
04-18 14:51:25.771 12867-12867/? I/DEBUG:     rax 0000000000000000  rbx 0000000000005220  rcx ffffffffffffffff  rdx 0000000000000006
04-18 14:51:25.771 12867-12867/? I/DEBUG:     rsi 0000000000005220  rdi 00000000000051a9
04-18 14:51:25.771 12867-12867/? I/DEBUG:     r8  0000000000000018  r9  00007f7652a76668  r10 0000000000000008  r11 0000000000000206
04-18 14:51:25.771 12867-12867/? I/DEBUG:     r12 0000000000000002  r13 0000000000000006  r14 0000000000000010  r15 00007f763be2a9e0
04-18 14:51:25.771 12867-12867/? I/DEBUG:     cs  0000000000000033  ss  000000000000002b
04-18 14:51:25.771 12867-12867/? I/DEBUG:     rip 00007f7653944507  rbp 00007f76398efb70  rsp 00007f76398ee518  eflags 0000000000000206
04-18 14:51:25.772 12867-12867/? I/DEBUG: backtrace:
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #00 pc 0000000000076507  /system/lib64/libc.so (tgkill+7)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #01 pc 000000000002829f  /system/lib64/libc.so (pthread_kill+143)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #02 pc 0000000000029571  /system/lib64/libc.so (raise+17)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #03 pc 0000000000022e1d  /system/lib64/libc.so (abort+61)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #04 pc 0000000000023143  /system/lib64/libbcc.so (ELFObject<64u>::relocateX86_64(void* (*)(void*, char const*), void*, ELFSectionRelTable<64u>*, ELFSectionProgBits<64u>*)+1603)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #05 pc 0000000000020d6f  /system/lib64/libbcc.so (ELFObject<64u>::relocate(void* (*)(void*, char const*), void*)+1071)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #06 pc 0000000000020909  /system/lib64/libbcc.so (bcc::ELFObjectLoaderImpl::relocate(bcc::SymbolResolverInterface&)+25)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #07 pc 0000000000029844  /system/lib64/libbcc.so (bcc::ObjectLoader::Load(void*, unsigned long, char const*, bcc::SymbolResolverInterface&, bool)+164)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #08 pc 0000000000029b54  /system/lib64/libbcc.so (bcc::ObjectLoader::Load(bcc::FileBase&, bcc::SymbolResolverInterface&, bool)+436)
04-18 14:51:25.772 12867-12867/? I/DEBUG:     #09 pc 000000000001791c  /system/lib64/libbcc.so (bcc::RSExecutable::Create(bcc::RSInfo&, bcc::FileBase&, bcc::SymbolResolverProxy&)+44)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #10 pc 0000000000015d07  /system/lib64/libbcc.so (bcc::RSCompilerDriver::loadScript(char const*, char const*, char const*, unsigned long, char const*, bcc::SymbolResolverProxy&)+2423)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #11 pc 0000000000012e5c  /system/lib64/libRSCpuRef.so (android::renderscript::RsdCpuScriptImpl::init(char const*, char const*, unsigned char const*, unsigned long, unsigned int, char const*)+3132)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #12 pc 0000000000011e34  /system/lib64/libRSCpuRef.so (android::renderscript::RsdCpuReferenceImpl::createScript(android::renderscript::ScriptC const*, char const*, char const*, unsigned char const*, unsigned long, unsigned int)+100)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #13 pc 0000000000014800  /system/lib64/libRSDriver.so (rsdScriptInit(android::renderscript::Context const*, android::renderscript::ScriptC*, char const*, char const*, unsigned char const*, unsigned long, unsigned int)+32)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #14 pc 000000000003e58c  /system/lib64/libRS.so (android::renderscript::ScriptC::runCompiler(android::renderscript::Context*, char const*, char const*, unsigned char const*, unsigned long)+380)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #15 pc 000000000003eb13  /system/lib64/libRS.so (android::renderscript::rsi_ScriptCCreate(android::renderscript::Context*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long)+99)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #16 pc 000000000004615a  /system/lib64/libRS.so (android::renderscript::rsp_ScriptCCreate(android::renderscript::Context*, void const*, unsigned long)+42)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #17 pc 0000000000042185  /system/lib64/libRS.so (android::renderscript::ThreadIO::playCoreCommands(android::renderscript::Context*, int)+453)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #18 pc 000000000002dd7f  /system/lib64/libRS.so (android::renderscript::Context::threadProc(void*)+2207)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #19 pc 000000000002731e  /system/lib64/libc.so (__pthread_start(void*)+46)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #20 pc 000000000002339b  /system/lib64/libc.so (__start_thread+11)
04-18 14:51:25.773 12867-12867/? I/DEBUG:     #21 pc 0000000000019885  /system/lib64/libc.so (__bionic_clone+53)
04-18 14:51:25.886 12867-12867/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_01

App module build.gradle

android {
    buildToolsVersion versions.buildToolsVersion
    compileSdkVersion versions.compileSdk

    defaultConfig {
        minSdkVersion versions.minSdk
        targetSdkVersion versions.targetSdk
    }
}

dependencies {
    implementation project(":shared")
    implementation project(":presentation")
    implementation project(":domain")
    implementation project(":data")
}

Data module build.gradle

android {
    buildToolsVersion versions.buildToolsVersion
    compileSdkVersion versions.compileSdk

    defaultConfig {
        minSdkVersion versions.minSdk
        targetSdkVersion versions.targetSdk

        renderscriptTargetApi 21
        renderscriptSupportModeEnabled false
    }
}

Project level build.gradle

buildscript {
    ext.versions = [
            'compileSdk'      : 29,
            'minSdk'          : 21,
            'targetSdk'       : 29,

            'buildToolsVersion': '29.0.3'
    ]
}

Where have I gone wrong?

Upvotes: 1

Views: 575

Answers (1)

Michiel
Michiel

Reputation: 768

It was obvious: rs_allocation and any relation functions were added in API 22. I'll set renderscriptSupportModeEnabled to true and in the future I'll use dynamic features to decrease the size for API 22+ drastically.

Upvotes: 1

Related Questions