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

SIGBUS error while inflate on armv7 #925

Closed
githublulz opened this issue Apr 8, 2021 · 14 comments
Closed

SIGBUS error while inflate on armv7 #925

githublulz opened this issue Apr 8, 2021 · 14 comments

Comments

@githublulz
Copy link

githublulz commented Apr 8, 2021

Hello,
I got a SIGBUS error on Android device when inflating compressed data. Any ideas ?
Original zlib inflate function work fine with the same code (without zng_ prefix). Deflate function work also fine with zlib-ng.

Static libs are built with Android NDK with following args :

cmake -B${ABI_BUILD_DIR} \
        -DANDROID_ABI=armeabi-v7a \
	-DWITH_GZFILEOP=OFF \
	-DCMAKE_C_FLAGS="-fdata-sections -ffunction-sections" \
        -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${STAGING_DIR}/lib/${ABI} \
        -DANDROID_PLATFORM=android-${MINIMUM_API_LEVEL} \
        -DZLIB_ENABLE_TESTS=OFF \
	-DCMAKE_BUILD_TYPE=Release \
	-DANDROID_TOOLCHAIN=clang \
	-DANDROID_STL=c++_shared \
	-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
	-DCMAKE_INSTALL_PREFIX=."

Stack-trace :

libc    : Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xff9cf895 in tid 16771 (binary), pid 16771 (binary)
04-08 19:45:11.273 16777 16777 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-08 19:45:11.273 16777 16777 F DEBUG   : Build fingerprint: 'samsung/a40eea/a40:9'
04-08 19:45:11.273 16777 16777 F DEBUG   : Revision: '4'
04-08 19:45:11.273 16777 16777 F DEBUG   : ABI: 'arm'
04-08 19:45:11.273 16777 16777 F DEBUG   : pid: 16771, tid: 16771, name: binary  >>> ./binary <<<
04-08 19:45:11.273 16777 16777 F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xff9cf895
04-08 19:45:11.274 16777 16777 F DEBUG   :     r0  00000001  r1  00000002  r2  0000002f  r3  ae393ac1
04-08 19:45:11.274 16777 16777 F DEBUG   :     r4  ff9cf897  r5  0000002f  r6  00000002  r7  ff9cef78
04-08 19:45:11.274 16777 16777 F DEBUG   :     r8  ff9cf895  r9  e8d49fec  r10 e92b8d94  r11 ff70da1c
04-08 19:45:11.274 16777 16777 F DEBUG   :     ip  036ff27f  sp  ff9cef50  lr  ae391d3f  pc  ae393b3c
04-08 19:45:11.290 16777 16777 F DEBUG   : 
04-08 19:45:11.290 16777 16777 F DEBUG   : backtrace:
04-08 19:45:11.290 16777 16777 F DEBUG   :     #00 pc 001feb3c  /data/local/tmp/binary (chunkmemset_neon+124)
04-08 19:45:11.290 16777 16777 F DEBUG   :     #01 pc 001fcd3d  /data/local/tmp/binary (zng_inflate_fast+588)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #02 pc 001fc683  /data/local/tmp/binary (zng_inflate+4678)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #03 pc 000810e7  /data/local/tmp/binary (zlibDecompress(unsigned char*, unsigned int, std::__ndk1::vector<char, std::__ndk1::allocator<char>>*)+130)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #04 pc 000813c7  /data/local/tmp/binary (#####+98)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #05 pc 000828e7  /data/local/tmp/binary (#####+1718)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #06 pc 0007a08b  /data/local/tmp/binary (#####+506)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #07 pc 0007c5bd  /data/local/tmp/binary (#####+408)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #08 pc 0007d373  /data/local/tmp/binary (#####1254)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #09 pc 000859a7  /data/local/tmp/binary (#####"+118)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #10 pc 00085bdd  /data/local/tmp/binary (main+92)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #11 pc 0008c34d  /system/lib/libc.so (__libc_init+48)
04-08 19:45:11.291 16777 16777 F DEBUG   :     #12 pc 00072288  /data/local/tmp/binary (_start_main+64)

Code (work fine with original zlib inflate) :

#define DECOMPRESS_CHUNK 16384
int zlibDecompress(unsigned char * compressed, size_t compressedLen, std::vector<char> * decompressed)
{
    int ret;
    unsigned have;
    zng_stream strm;
    unsigned char out[DECOMPRESS_CHUNK];

    size_t alreadyDecompressed = 0;

    /* allocate inflate state */
    strm.zalloc = Z_NULL;
    strm.zfree = Z_NULL;
    strm.opaque = Z_NULL;
    strm.avail_in = 0;
    strm.next_in = Z_NULL;
    ret = zng_inflateInit(&strm);
    if (ret != Z_OK)
        return ret;

    /* decompress until deflate stream ends or end of file */
    do {
        if (alreadyDecompressed + DECOMPRESS_CHUNK > compressedLen)
            strm.avail_in = compressedLen % DECOMPRESS_CHUNK;
        else
            strm.avail_in = DECOMPRESS_CHUNK;

        if (strm.avail_in == 0)
            break;

        strm.next_in = compressed + alreadyDecompressed;

        /* run inflate() on input until output buffer not full */
        do {
            strm.avail_out = DECOMPRESS_CHUNK;
            strm.next_out = out;
            ret = zng_inflate(&strm, Z_NO_FLUSH);

            if (ret == Z_STREAM_ERROR) {
                printf("zlibDecompress: Internal error");
                return Z_STREAM_ERROR;
            }
            switch (ret) {
                case Z_NEED_DICT:
                    ret = Z_DATA_ERROR;     /* and fall through */
                case Z_DATA_ERROR:
                case Z_MEM_ERROR:
                    (void)zng_inflateEnd(&strm);
                    return ret;
            }
            have = DECOMPRESS_CHUNK - strm.avail_out;
            decompressed->insert(decompressed->end(), out, out+have);

        } while (strm.avail_out == 0);

        alreadyDecompressed += DECOMPRESS_CHUNK;
        /* done when inflate() says it's done */

        if (strm.avail_in != DECOMPRESS_CHUNK)
            break;

    } while (ret != Z_STREAM_END);

    /* clean up and return */
    (void)zng_inflateEnd(&strm);
    return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
@Dead2
Copy link
Member

Dead2 commented Apr 8, 2021

Some more information I think we would like to see here:

  • What version of zlib-ng is this? Is it one of the release tarballs and what commit?
  • Please copy-paste the output of the CMake command, it lets us know a bit more about how zlib-ng was compiled for your platform.

I also just merged a few fixes into develop, one of them concerning arm floatingpoint, so testing with that (or without if this was already with that) might be worth it. This crash is in neon code, so it might be relevant.
And what happens if you build and run the tests?

@Dead2
Copy link
Member

Dead2 commented Apr 8, 2021

Oh, sorry, the fixes I was thinking about are still in #918, they almost made it into develop earlier.

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 8, 2021

BUS_ADRALN means alignment violation. We can diagnose more after we see the cmake output...

kdrag0n added a commit to ProtonAOSP/android_external_zlib-ng that referenced this issue Apr 9, 2021
This fixes crashes caused by unaligned accesses on 32-bit ARM:

F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG   : Build fingerprint: 'google/taimen/taimen:11/RP1A.201005.004.A1/6934943:user/release-keys'
F DEBUG   : Revision: 'rev_10'
F DEBUG   : ABI: 'arm'
F DEBUG   : Timestamp: 2021-04-08 22:22:37+0000
F DEBUG   : pid: 14337, tid: 14337, name: webview_service  >>> com.android.webview:webview_service <<<
F DEBUG   : uid: 10152
F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xe0ffc151
F DEBUG   :     r0  fffffffc  r1  00000003  r2  0000007f  r3  ed971f45
F DEBUG   :     r4  e0ffc155  r5  e0ffc151  r6  0000007f  r7  00000004
F DEBUG   :     r8  0000002b  r9  edc36134  r10 00ece229  r11 ffffffff
F DEBUG   :     ip  0ece2291  sp  fffc0a08  lr  ed96f3fb  pc  ed971fd4
F DEBUG   : backtrace:
F DEBUG   :       #00 pc 00058fd4  /apex/com.android.art/lib/libartbase.so (chunkmemset_neon+144) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #1 pc 000563f9  /apex/com.android.art/lib/libartbase.so (zng_inflate_fast+840) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #2 pc 0005539f  /apex/com.android.art/lib/libartbase.so (inflate+3754) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #03 pc 0004f36d  /apex/com.android.art/lib/libartbase.so (zip_archive::Inflate(zip_archive::Reader const&, unsigned int, unsigned int, zip_archive::Writer*, unsigned long long*)+224) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #04 pc 0004f697  /apex/com.android.art/lib/libartbase.so (ExtractToWriter(ZipArchive*, ZipEntry*, zip_archive::Writer*)+202) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #05 pc 0004f80d  /apex/com.android.art/lib/libartbase.so (ExtractToMemory(ZipArchive*, ZipEntry*, unsigned char*, unsigned int)+36) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #06 pc 00023fd9  /apex/com.android.art/lib/libartbase.so (art::ZipEntry::ExtractToMemMap(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+220) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #07 pc 000169c1  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenOneDexFileFromZip(art::ZipArchive const&, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, art::DexFileLoaderErrorCode*) const+492) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #08 pc 000164cd  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenAllDexFilesFromZip(art::ZipArchive const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+112) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #09 pc 000163a7  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenZip(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+122) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #10 pc 000161f3  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenWithMagic(unsigned int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+178) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #11 pc 0001611d  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::Open(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+96) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #12 pc 003a5c33  /apex/com.android.art/lib/libart.so (art::OatFileManager::OpenDexFilesFromOat(char const*, _jobject*, _jobjectArray*, art::OatFile const**, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*)+3090) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #13 pc 0036ae69  /apex/com.android.art/lib/libart.so (art::DexFile_openDexFileNative(_JNIEnv*, _jclass*, _jstring*, _jstring*, int, _jobject*, _jobjectArray*)+92) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #14 pc 0000d6a3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (art_jni_trampoline+194) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #15 pc 00016dab  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexFile.openDexFile+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #16 pc 00018499  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.makeDexElements+552) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #17 pc 00017e93  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.<init>+514) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #18 pc 000157b3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.BaseDexClassLoader.<init>+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #19 pc 0003aa6d  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.PathClassLoader.<init>+68) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #20 pc 00712405  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+612) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #21 pc 007124d1  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+64) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #22 pc 002cab99  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoader+280) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #23 pc 002cb23d  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries+92) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #24 pc 002d3671  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.createOrUpdateClassLoaderLocked+3528) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #25 pc 002d5ef5  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getClassLoader+76) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #26 pc 002d63a3  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getResources+322) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #27 pc 00397121  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+152) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #28 pc 00397075  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+44) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #29 pc 0037a841  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.handleBindApplication+4816) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #30 pc 003718f9  /system/framework/arm/boot-framework.oat (android.app.ActivityThread$H.handleMessage+6232) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #31 pc 00539d71  /system/framework/arm/boot-framework.oat (android.os.Handler.dispatchMessage+136) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #32 pc 0053c751  /system/framework/arm/boot-framework.oat (android.os.Looper.loop+1352) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #33 pc 00380a21  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.main+760) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #34 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #35 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #36 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #37 pc 003f345b  /apex/com.android.art/lib/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned int)+910) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #38 pc 00392fb3  /apex/com.android.art/lib/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+30) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #39 pc 00084667  /apex/com.android.art/javalib/arm/boot.oat (art_jni_trampoline+110) (BuildId: d70d31c62cc931b5110ecd17558e117d5639fc0b)
F DEBUG   :       #40 pc 00719c49  /system/framework/arm/boot-framework.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+112) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #41 pc 00720c87  /system/framework/arm/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2014) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #42 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #43 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #44 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #45 pc 003f25bf  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+350) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #46 pc 003f2867  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+42) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #47 pc 0031d491  /apex/com.android.art/lib/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+456) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #48 pc 000667a9  /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+28) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #49 pc 0006c417  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+602) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #50 pc 00002def  /system/bin/app_process32 (main+982) (BuildId: ac98b39d91c544fc9bae40f1ad1de585)
F DEBUG   :       #51 pc 00064049  /apex/com.android.runtime/lib/bionic/libc.so (__libc_init+56) (BuildId: 2fb9d5dbba686f16b13e324249a9fb48)

TOOD: Investigate further and get this fixed in upstream, if applicable.
This might be related to zlib-ng/zlib-ng#925.
kdrag0n added a commit to ProtonAOSP/android_external_zlib-ng that referenced this issue Apr 9, 2021
This fixes crashes caused by unaligned accesses on 32-bit ARM:

F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG   : Build fingerprint: 'google/taimen/taimen:11/RP1A.201005.004.A1/6934943:user/release-keys'
F DEBUG   : Revision: 'rev_10'
F DEBUG   : ABI: 'arm'
F DEBUG   : Timestamp: 2021-04-08 22:22:37+0000
F DEBUG   : pid: 14337, tid: 14337, name: webview_service  >>> com.android.webview:webview_service <<<
F DEBUG   : uid: 10152
F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xe0ffc151
F DEBUG   :     r0  fffffffc  r1  00000003  r2  0000007f  r3  ed971f45
F DEBUG   :     r4  e0ffc155  r5  e0ffc151  r6  0000007f  r7  00000004
F DEBUG   :     r8  0000002b  r9  edc36134  r10 00ece229  r11 ffffffff
F DEBUG   :     ip  0ece2291  sp  fffc0a08  lr  ed96f3fb  pc  ed971fd4
F DEBUG   : backtrace:
F DEBUG   :       #00 pc 00058fd4  /apex/com.android.art/lib/libartbase.so (chunkmemset_neon+144) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #1 pc 000563f9  /apex/com.android.art/lib/libartbase.so (zng_inflate_fast+840) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #2 pc 0005539f  /apex/com.android.art/lib/libartbase.so (inflate+3754) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #03 pc 0004f36d  /apex/com.android.art/lib/libartbase.so (zip_archive::Inflate(zip_archive::Reader const&, unsigned int, unsigned int, zip_archive::Writer*, unsigned long long*)+224) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #04 pc 0004f697  /apex/com.android.art/lib/libartbase.so (ExtractToWriter(ZipArchive*, ZipEntry*, zip_archive::Writer*)+202) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #05 pc 0004f80d  /apex/com.android.art/lib/libartbase.so (ExtractToMemory(ZipArchive*, ZipEntry*, unsigned char*, unsigned int)+36) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #06 pc 00023fd9  /apex/com.android.art/lib/libartbase.so (art::ZipEntry::ExtractToMemMap(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+220) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #07 pc 000169c1  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenOneDexFileFromZip(art::ZipArchive const&, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, art::DexFileLoaderErrorCode*) const+492) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #08 pc 000164cd  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenAllDexFilesFromZip(art::ZipArchive const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+112) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #09 pc 000163a7  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenZip(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+122) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #10 pc 000161f3  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenWithMagic(unsigned int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+178) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #11 pc 0001611d  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::Open(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+96) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #12 pc 003a5c33  /apex/com.android.art/lib/libart.so (art::OatFileManager::OpenDexFilesFromOat(char const*, _jobject*, _jobjectArray*, art::OatFile const**, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*)+3090) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #13 pc 0036ae69  /apex/com.android.art/lib/libart.so (art::DexFile_openDexFileNative(_JNIEnv*, _jclass*, _jstring*, _jstring*, int, _jobject*, _jobjectArray*)+92) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #14 pc 0000d6a3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (art_jni_trampoline+194) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #15 pc 00016dab  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexFile.openDexFile+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #16 pc 00018499  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.makeDexElements+552) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #17 pc 00017e93  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.<init>+514) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #18 pc 000157b3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.BaseDexClassLoader.<init>+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #19 pc 0003aa6d  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.PathClassLoader.<init>+68) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #20 pc 00712405  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+612) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #21 pc 007124d1  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+64) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #22 pc 002cab99  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoader+280) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #23 pc 002cb23d  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries+92) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #24 pc 002d3671  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.createOrUpdateClassLoaderLocked+3528) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #25 pc 002d5ef5  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getClassLoader+76) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #26 pc 002d63a3  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getResources+322) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #27 pc 00397121  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+152) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #28 pc 00397075  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+44) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #29 pc 0037a841  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.handleBindApplication+4816) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #30 pc 003718f9  /system/framework/arm/boot-framework.oat (android.app.ActivityThread$H.handleMessage+6232) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #31 pc 00539d71  /system/framework/arm/boot-framework.oat (android.os.Handler.dispatchMessage+136) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #32 pc 0053c751  /system/framework/arm/boot-framework.oat (android.os.Looper.loop+1352) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #33 pc 00380a21  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.main+760) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #34 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #35 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #36 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #37 pc 003f345b  /apex/com.android.art/lib/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned int)+910) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #38 pc 00392fb3  /apex/com.android.art/lib/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+30) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #39 pc 00084667  /apex/com.android.art/javalib/arm/boot.oat (art_jni_trampoline+110) (BuildId: d70d31c62cc931b5110ecd17558e117d5639fc0b)
F DEBUG   :       #40 pc 00719c49  /system/framework/arm/boot-framework.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+112) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #41 pc 00720c87  /system/framework/arm/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2014) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #42 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #43 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #44 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #45 pc 003f25bf  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+350) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #46 pc 003f2867  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+42) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #47 pc 0031d491  /apex/com.android.art/lib/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+456) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #48 pc 000667a9  /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+28) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #49 pc 0006c417  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+602) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #50 pc 00002def  /system/bin/app_process32 (main+982) (BuildId: ac98b39d91c544fc9bae40f1ad1de585)
F DEBUG   :       #51 pc 00064049  /apex/com.android.runtime/lib/bionic/libc.so (__libc_init+56) (BuildId: 2fb9d5dbba686f16b13e324249a9fb48)

TOOD: Investigate further and get this fixed in upstream, if applicable.
This might be related to zlib-ng/zlib-ng#925.
kdrag0n added a commit to ProtonAOSP/android_external_zlib-ng that referenced this issue Apr 9, 2021
In combination with disabling unaligned accesses, this fixes SIGBUS
BUS_ADRALN crashes on 32-bit ARM:

F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG   : Build fingerprint: 'google/taimen/taimen:11/RP1A.201005.004.A1/6934943:user/release-keys'
F DEBUG   : Revision: 'rev_10'
F DEBUG   : ABI: 'arm'
F DEBUG   : Timestamp: 2021-04-08 22:22:37+0000
F DEBUG   : pid: 14337, tid: 14337, name: webview_service  >>> com.android.webview:webview_service <<<
F DEBUG   : uid: 10152
F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xe0ffc151
F DEBUG   :     r0  fffffffc  r1  00000003  r2  0000007f  r3  ed971f45
F DEBUG   :     r4  e0ffc155  r5  e0ffc151  r6  0000007f  r7  00000004
F DEBUG   :     r8  0000002b  r9  edc36134  r10 00ece229  r11 ffffffff
F DEBUG   :     ip  0ece2291  sp  fffc0a08  lr  ed96f3fb  pc  ed971fd4
F DEBUG   : backtrace:
F DEBUG   :       #00 pc 00058fd4  /apex/com.android.art/lib/libartbase.so (chunkmemset_neon+144) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #1 pc 000563f9  /apex/com.android.art/lib/libartbase.so (zng_inflate_fast+840) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #2 pc 0005539f  /apex/com.android.art/lib/libartbase.so (inflate+3754) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #03 pc 0004f36d  /apex/com.android.art/lib/libartbase.so (zip_archive::Inflate(zip_archive::Reader const&, unsigned int, unsigned int, zip_archive::Writer*, unsigned long long*)+224) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #04 pc 0004f697  /apex/com.android.art/lib/libartbase.so (ExtractToWriter(ZipArchive*, ZipEntry*, zip_archive::Writer*)+202) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #05 pc 0004f80d  /apex/com.android.art/lib/libartbase.so (ExtractToMemory(ZipArchive*, ZipEntry*, unsigned char*, unsigned int)+36) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #06 pc 00023fd9  /apex/com.android.art/lib/libartbase.so (art::ZipEntry::ExtractToMemMap(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+220) (BuildId: d6d3c93fcc0f81a9f2aa574923a873f7)
F DEBUG   :       #07 pc 000169c1  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenOneDexFileFromZip(art::ZipArchive const&, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, art::DexFileLoaderErrorCode*) const+492) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #08 pc 000164cd  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenAllDexFilesFromZip(art::ZipArchive const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+112) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #09 pc 000163a7  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenZip(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+122) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #10 pc 000161f3  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::OpenWithMagic(unsigned int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+178) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #11 pc 0001611d  /apex/com.android.art/lib/libdexfile.so (art::ArtDexFileLoader::Open(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::vector<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> >, std::__1::allocator<std::__1::unique_ptr<art::DexFile const, std::__1::default_delete<art::DexFile const> > > >*) const+96) (BuildId: 03c2a39a39fbf134d85e03dfb27560d0)
F DEBUG   :       #12 pc 003a5c33  /apex/com.android.art/lib/libart.so (art::OatFileManager::OpenDexFilesFromOat(char const*, _jobject*, _jobjectArray*, art::OatFile const**, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*)+3090) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #13 pc 0036ae69  /apex/com.android.art/lib/libart.so (art::DexFile_openDexFileNative(_JNIEnv*, _jclass*, _jstring*, _jstring*, int, _jobject*, _jobjectArray*)+92) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #14 pc 0000d6a3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (art_jni_trampoline+194) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #15 pc 00016dab  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexFile.openDexFile+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #16 pc 00018499  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.makeDexElements+552) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #17 pc 00017e93  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.DexPathList.<init>+514) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #18 pc 000157b3  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.BaseDexClassLoader.<init>+186) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #19 pc 0003aa6d  /apex/com.android.art/javalib/arm/boot-core-libart.oat (dalvik.system.PathClassLoader.<init>+68) (BuildId: 9d0fb0eebcfd3ec2d8ce3e5a5c90e8b6f7383f85)
F DEBUG   :       #20 pc 00712405  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+612) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #21 pc 007124d1  /system/framework/arm/boot-framework.oat (com.android.internal.os.ClassLoaderFactory.createClassLoader+64) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #22 pc 002cab99  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoader+280) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #23 pc 002cb23d  /system/framework/arm/boot-framework.oat (android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries+92) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #24 pc 002d3671  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.createOrUpdateClassLoaderLocked+3528) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #25 pc 002d5ef5  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getClassLoader+76) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #26 pc 002d63a3  /system/framework/arm/boot-framework.oat (android.app.LoadedApk.getResources+322) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #27 pc 00397121  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+152) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #28 pc 00397075  /system/framework/arm/boot-framework.oat (android.app.ContextImpl.createAppContext+44) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #29 pc 0037a841  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.handleBindApplication+4816) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #30 pc 003718f9  /system/framework/arm/boot-framework.oat (android.app.ActivityThread$H.handleMessage+6232) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #31 pc 00539d71  /system/framework/arm/boot-framework.oat (android.os.Handler.dispatchMessage+136) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #32 pc 0053c751  /system/framework/arm/boot-framework.oat (android.os.Looper.loop+1352) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #33 pc 00380a21  /system/framework/arm/boot-framework.oat (android.app.ActivityThread.main+760) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #34 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #35 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #36 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #37 pc 003f345b  /apex/com.android.art/lib/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned int)+910) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #38 pc 00392fb3  /apex/com.android.art/lib/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+30) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #39 pc 00084667  /apex/com.android.art/javalib/arm/boot.oat (art_jni_trampoline+110) (BuildId: d70d31c62cc931b5110ecd17558e117d5639fc0b)
F DEBUG   :       #40 pc 00719c49  /system/framework/arm/boot-framework.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+112) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #41 pc 00720c87  /system/framework/arm/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2014) (BuildId: bba22a9b28b46e97cd6773218485b53842fe5282)
F DEBUG   :       #42 pc 000d3dd5  /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #43 pc 004e1809  /apex/com.android.art/lib/libart.so (art_quick_invoke_static_stub+284) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #44 pc 00130915  /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+168) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #45 pc 003f25bf  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+350) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #46 pc 003f2867  /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+42) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #47 pc 0031d491  /apex/com.android.art/lib/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+456) (BuildId: 61578d3ef0e0d1143a9de82940bcb47b)
F DEBUG   :       #48 pc 000667a9  /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+28) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #49 pc 0006c417  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+602) (BuildId: 77564f1e3925eb821e5acb1a0447509b)
F DEBUG   :       #50 pc 00002def  /system/bin/app_process32 (main+982) (BuildId: ac98b39d91c544fc9bae40f1ad1de585)
F DEBUG   :       #51 pc 00064049  /apex/com.android.runtime/lib/bionic/libc.so (__libc_init+56) (BuildId: 2fb9d5dbba686f16b13e324249a9fb48)

TOOD: Investigate further and get this fixed in upstream, if applicable.
This might be related to zlib-ng/zlib-ng#925.
@githublulz
Copy link
Author

It's zlib-ng version 2.0.2 and code is from git tag 2.0.2.

Cmake output :

-- Using CMake version 3.10.2
-- ZLIB_HEADER_VERSION: 1.2.11
-- ZLIBNG_HEADER_VERSION: 2.0.2
-- The C compiler identification is Clang 11.0.5
-- Check for working C compiler: /opt/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /opt/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Arch detected: 'armv7-none-linux-androideabi23'
-- Basearch of 'armv7-none-linux-androideabi23' has been detected as: 'arm'
-- Using CMake toolchain: /opt/android-ndk-r22/build/cmake/android.toolchain.cmake
-- ARM floating point arch: 
-- Performing Test MFPU_NEON_AVAILABLE
-- Performing Test MFPU_NEON_AVAILABLE - Success
-- Architecture supports unaligned reads
-- Architecture supports unaligned reads of > 4 bytes
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for sys/sdt.h
-- Looking for sys/sdt.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for strerror
-- Looking for strerror - found
-- Performing Test HAVE_NO_INTERPOSITION
-- Performing Test HAVE_NO_INTERPOSITION - Success
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN - Success
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL - Success
-- Performing Test HAVE_BUILTIN_CTZ
-- Performing Test HAVE_BUILTIN_CTZ - Success
-- Performing Test HAVE_BUILTIN_CTZLL
-- Performing Test HAVE_BUILTIN_CTZLL - Success
-- Performing Test HAVE_PTRDIFF_T
-- Performing Test HAVE_PTRDIFF_T - Success
-- Architecture-specific source files: arch/arm/armfeature.c;arch/arm/crc32_acle.c;arch/arm/insert_string_acle.c;arch/arm/adler32_neon.c;arch/arm/chunkset_neon.c;arch/arm/slide_neon.c
-- The following features have been enabled:

 * CMAKE_BUILD_TYPE, Build type: Release (selected)
 * WITH_OPTIM, Build with optimisation
 * WITH_NEW_STRATEGIES, Use new strategies
 * WITH_UNALIGNED, Support unaligned reads on platforms that support it
 * WITH_ACLE, Build with ACLE
 * WITH_NEON, Build with NEON intrinsics
 * ACLE_CRC, Support ACLE optimized CRC hash generation, using "-march=armv8-a+crc"
 * NEON_ADLER32, Support NEON instructions in adler32, using "-mfpu=neon"
 * NEON_SLIDEHASH, Support NEON instructions in slide_hash, using "-mfpu=neon"

-- The following features have been disabled:

 * WITH_GZFILEOP, Compile with support for gzFile related functions
 * ZLIB_COMPAT, Compile with zlib compatible API
 * ZLIB_ENABLE_TESTS, Build test binaries
 * ZLIB_DUAL_LINK, Dual link tests against system zlib
 * WITH_SANITIZER, Build with sanitizer (Memory, Address, Undefined)
 * WITH_FUZZERS, Build test/fuzz
 * WITH_NATIVE_INSTRUCTIONS, Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)
 * WITH_MAINTAINER_WARNINGS, Build with project maintainer warnings
 * WITH_CODE_COVERAGE, Enable code coverage reporting
 * WITH_INFLATE_STRICT, Build with strict inflate distance checking
 * WITH_INFLATE_ALLOW_INVALID_DIST, Build with zero fill for inflate invalid distances
 * INSTALL_UTILS, Copy minigzip and minideflate during install

-- Configuring done
-- Generating done

Make build output :

Scanning dependencies of target zlib
Scanning dependencies of target zlibstatic
[  1%] Building C object CMakeFiles/zlib.dir/adler32.c.o
[  3%] Building C object CMakeFiles/zlibstatic.dir/chunkset.c.o
[  5%] Building C object CMakeFiles/zlibstatic.dir/adler32.c.o
[  7%] Building C object CMakeFiles/zlib.dir/chunkset.c.o
[  9%] Building C object CMakeFiles/zlib.dir/compare258.c.o
[ 11%] Building C object CMakeFiles/zlibstatic.dir/compress.c.o
[ 12%] Building C object CMakeFiles/zlibstatic.dir/compare258.c.o
[ 14%] Building C object CMakeFiles/zlib.dir/compress.c.o
[ 16%] Building C object CMakeFiles/zlibstatic.dir/crc32.c.o
[ 18%] Building C object CMakeFiles/zlibstatic.dir/crc32_comb.c.o
[ 20%] Building C object CMakeFiles/zlib.dir/crc32.c.o
[ 22%] Building C object CMakeFiles/zlibstatic.dir/deflate.c.o
[ 24%] Building C object CMakeFiles/zlibstatic.dir/deflate_fast.c.o
[ 25%] Building C object CMakeFiles/zlib.dir/crc32_comb.c.o
[ 27%] Building C object CMakeFiles/zlib.dir/deflate.c.o
[ 29%] Building C object CMakeFiles/zlibstatic.dir/deflate_medium.c.o
[ 31%] Building C object CMakeFiles/zlib.dir/deflate_fast.c.o
[ 33%] Building C object CMakeFiles/zlibstatic.dir/deflate_quick.c.o
[ 35%] Building C object CMakeFiles/zlib.dir/deflate_medium.c.o
[ 37%] Building C object CMakeFiles/zlibstatic.dir/deflate_slow.c.o
[ 38%] Building C object CMakeFiles/zlibstatic.dir/functable.c.o
[ 40%] Building C object CMakeFiles/zlib.dir/deflate_quick.c.o
[ 42%] Building C object CMakeFiles/zlibstatic.dir/infback.c.o
[ 44%] Building C object CMakeFiles/zlibstatic.dir/inffast.c.o
[ 46%] Building C object CMakeFiles/zlib.dir/deflate_slow.c.o
[ 48%] Building C object CMakeFiles/zlibstatic.dir/inflate.c.o
[ 50%] Building C object CMakeFiles/zlib.dir/functable.c.o
[ 51%] Building C object CMakeFiles/zlibstatic.dir/inftrees.c.o
[ 53%] Building C object CMakeFiles/zlib.dir/infback.c.o
[ 55%] Building C object CMakeFiles/zlib.dir/inffast.c.o
[ 57%] Building C object CMakeFiles/zlibstatic.dir/insert_string.c.o
[ 59%] Building C object CMakeFiles/zlibstatic.dir/trees.c.o
[ 61%] Building C object CMakeFiles/zlib.dir/inflate.c.o
[ 62%] Building C object CMakeFiles/zlibstatic.dir/uncompr.c.o
[ 64%] Building C object CMakeFiles/zlib.dir/inftrees.c.o
[ 66%] Building C object CMakeFiles/zlib.dir/insert_string.c.o
[ 68%] Building C object CMakeFiles/zlibstatic.dir/zutil.c.o
[ 70%] Building C object CMakeFiles/zlib.dir/trees.c.o
[ 72%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/armfeature.c.o
[ 74%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/crc32_acle.c.o
[ 75%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/insert_string_acle.c.o
[ 77%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/adler32_neon.c.o
[ 79%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/chunkset_neon.c.o
[ 81%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/slide_neon.c.o
[ 83%] Building C object CMakeFiles/zlib.dir/uncompr.c.o
[ 85%] Building C object CMakeFiles/zlib.dir/zutil.c.o
[ 87%] Building C object CMakeFiles/zlib.dir/arch/arm/armfeature.c.o
[ 90%] Building C object CMakeFiles/zlib.dir/arch/arm/crc32_acle.c.o
[ 90%] Building C object CMakeFiles/zlib.dir/arch/arm/insert_string_acle.c.o
[ 92%] Linking C static library staging/lib/armeabi-v7a/libz-ng.a
[ 94%] Building C object CMakeFiles/zlib.dir/arch/arm/adler32_neon.c.o
[ 96%] Building C object CMakeFiles/zlib.dir/arch/arm/chunkset_neon.c.o
[ 98%] Building C object CMakeFiles/zlib.dir/arch/arm/slide_neon.c.o
[ 98%] Built target zlibstatic
[100%] Linking C shared library libz-ng.so
[100%] Built target zlib

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 9, 2021

Because it's alignment violation, we also need disassembly of the function chunkmemset_neon so we know the exact instruction (and line in source code) that causes the alignment violation.

Most of the code in chunkmemset_neon already use 8-bit wide reads and writes but obviously there is still some wider reads and writes using for example general-purpose registers.

@githublulz
Copy link
Author

githublulz commented Apr 9, 2021

Here the disassembly of the function chunkmemset_neon :
Do you need the complete object file ?

00000000 <chunkmemset_neon>:
   0:	b5f0      	push	{r4, r5, r6, r7, lr}
   2:	af03      	add	r7, sp, #12
   4:	e92d 07f0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, sl}
   8:	9201      	str	r2, [sp, #4]
   a:	4604      	mov	r4, r0
   c:	4844      	ldr	r0, [pc, #272]	; (120 <chunkmemset_neon+0x120>)
   e:	460e      	mov	r6, r1
  10:	2a0f      	cmp	r2, #15
  12:	4478      	add	r0, pc
  14:	f8d0 a000 	ldr.w	sl, [r0]
  18:	f8da 0000 	ldr.w	r0, [sl]
  1c:	9003      	str	r0, [sp, #12]
  1e:	9102      	str	r1, [sp, #8]
  20:	d808      	bhi.n	34 <chunkmemset_neon+0x34>
  22:	4270      	negs	r0, r6
  24:	5c21      	ldrb	r1, [r4, r0]
  26:	7021      	strb	r1, [r4, #0]
  28:	3401      	adds	r4, #1
  2a:	9901      	ldr	r1, [sp, #4]
  2c:	3901      	subs	r1, #1
  2e:	9101      	str	r1, [sp, #4]
  30:	d1f8      	bne.n	24 <chunkmemset_neon+0x24>
  32:	e040      	b.n	b6 <chunkmemset_neon+0xb6>
  34:	1e70      	subs	r0, r6, #1
  36:	eba4 0806 	sub.w	r8, r4, r6
  3a:	4615      	mov	r5, r2
  3c:	2807      	cmp	r0, #7
  3e:	d808      	bhi.n	52 <chunkmemset_neon+0x52>
  40:	e8df f000 	tbb	[pc, r0]
  44:	1f0c1c04 	.word	0x1f0c1c04
  48:	220c0c0c 	.word	0x220c0c0c
  4c:	f9e8 0c2f 	vld1.8	{d16[]-d17[]}, [r8]
  50:	e01e      	b.n	90 <chunkmemset_neon+0x90>
  52:	2e10      	cmp	r6, #16
  54:	d102      	bne.n	5c <chunkmemset_neon+0x5c>
  56:	f968 0a0f 	vld1.8	{d16-d17}, [r8]
  5a:	e019      	b.n	90 <chunkmemset_neon+0x90>
  5c:	2e0f      	cmp	r6, #15
  5e:	d835      	bhi.n	cc <chunkmemset_neon+0xcc>
  60:	1960      	adds	r0, r4, r5
  62:	f1a0 0901 	sub.w	r9, r0, #1
  66:	42b5      	cmp	r5, r6
  68:	d944      	bls.n	f4 <chunkmemset_neon+0xf4>
  6a:	4620      	mov	r0, r4
  6c:	4641      	mov	r1, r8
  6e:	4632      	mov	r2, r6
  70:	464b      	mov	r3, r9
  72:	f7ff fffe 	bl	0 <chunkmemset_neon>
  76:	4604      	mov	r4, r0
  78:	1bad      	subs	r5, r5, r6
  7a:	e7f4      	b.n	66 <chunkmemset_neon+0x66>
  7c:	f9e8 0c7f 	vld1.16	{d16[]-d17[]}, [r8 :16] <-- (chunkmemset_neon+124) ?
  80:	e006      	b.n	90 <chunkmemset_neon+0x90>
  82:	f9e8 0cbf 	vld1.32	{d16[]-d17[]}, [r8 :32]
  86:	e003      	b.n	90 <chunkmemset_neon+0x90>
  88:	f968 070f 	vld1.8	{d16}, [r8]
  8c:	ef60 11b0 	vorr	d17, d16, d16
  90:	f025 000f 	bic.w	r0, r5, #15
  94:	4240      	negs	r0, r0
  96:	b118      	cbz	r0, a0 <chunkmemset_neon+0xa0>
  98:	f944 0a0d 	vst1.8	{d16-d17}, [r4]!
  9c:	3010      	adds	r0, #16
  9e:	e7fa      	b.n	96 <chunkmemset_neon+0x96>
  a0:	2000      	movs	r0, #0
  a2:	f015 050f 	ands.w	r5, r5, #15
  a6:	9001      	str	r0, [sp, #4]
  a8:	d004      	beq.n	b4 <chunkmemset_neon+0xb4>
  aa:	4620      	mov	r0, r4
  ac:	4641      	mov	r1, r8
  ae:	462a      	mov	r2, r5
  b0:	f7ff fffe 	bl	0 <__aeabi_memcpy>
  b4:	442c      	add	r4, r5
  b6:	f8da 0000 	ldr.w	r0, [sl]
  ba:	9903      	ldr	r1, [sp, #12]
  bc:	4288      	cmp	r0, r1
  be:	bf01      	itttt	eq
  c0:	4620      	moveq	r0, r4
  c2:	b004      	addeq	sp, #16
  c4:	e8bd 0700 	ldmiaeq.w	sp!, {r8, r9, sl}
  c8:	bdf0      	popeq	{r4, r5, r6, r7, pc}
  ca:	e027      	b.n	11c <chunkmemset_neon+0x11c>
  cc:	a902      	add	r1, sp, #8
  ce:	aa01      	add	r2, sp, #4
  d0:	4620      	mov	r0, r4
  d2:	f7ff fffe 	bl	0 <chunkmemset_neon>
  d6:	e9dd 2101 	ldrd	r2, r1, [sp, #4]
  da:	f8da 3000 	ldr.w	r3, [sl]
  de:	9c03      	ldr	r4, [sp, #12]
  e0:	42a3      	cmp	r3, r4
  e2:	d11b      	bne.n	11c <chunkmemset_neon+0x11c>
  e4:	1a41      	subs	r1, r0, r1
  e6:	b004      	add	sp, #16
  e8:	e8bd 0700 	ldmia.w	sp!, {r8, r9, sl}
  ec:	e8bd 40f0 	ldmia.w	sp!, {r4, r5, r6, r7, lr}
  f0:	f7ff bffe 	b.w	0 <chunkmemset_neon>
  f4:	2d00      	cmp	r5, #0
  f6:	9501      	str	r5, [sp, #4]
  f8:	d0dd      	beq.n	b6 <chunkmemset_neon+0xb6>
  fa:	f8da 0000 	ldr.w	r0, [sl]
  fe:	9903      	ldr	r1, [sp, #12]
 100:	4288      	cmp	r0, r1
 102:	bf01      	itttt	eq
 104:	4620      	moveq	r0, r4
 106:	4641      	moveq	r1, r8
 108:	462a      	moveq	r2, r5
 10a:	464b      	moveq	r3, r9
 10c:	bf01      	itttt	eq
 10e:	b004      	addeq	sp, #16
 110:	e8bd 0700 	ldmiaeq.w	sp!, {r8, r9, sl}
 114:	e8bd 40f0 	ldmiaeq.w	sp!, {r4, r5, r6, r7, lr}
 118:	f7ff bffe 	beq.w	0 <chunkmemset_neon>
 11c:	f7ff fffe 	bl	0 <__stack_chk_fail>
 120:	0000010a 	.word	0x0000010a

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 9, 2021

Looking at the disassembly, I think chunkmemset_2 and chunkmemset_4 need temporary variable because NEON doesn't support unaligned loads wider than 8 bits under ARMv7 and earlier.

@nmoinvaz
Copy link
Member

nmoinvaz commented Apr 10, 2021

I think user should be using cmake . -DUNALIGNED_OK=OFF and then we have to add UNALIGNED_OK support into chunkset_neon.c. This is similar to how chunkset.c works.

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 11, 2021

@nmoinvaz UNALIGNED_OK is only used for general-purpose integer registers, not for floating point or vector registers. Not forgetting that it should be detected by the build system, not specified by the user.

@githublulz
Copy link
Author

Your fix works great. Thank you !

@NiLuJe
Copy link
Contributor

NiLuJe commented Apr 14, 2021

This appears to be a Clang code generation quirk?

  • According to Table A3-1 Alignment requirements of load/store instructions in the ARM DDI 0406C PDF, if unaligned accesses are allowed by the CPU, this (e.g., the alignment check is element sized, so, here, at worst, that's int32, which is just fine for an unaligned access on 32-bit) is perfectly sane... as long as there are no :align hints!

And therein lies the rub:

Clang appears to generate said align hints, despite that assumption being a tad optimistic. I checked w/ a plain Linux build targeting the Cortex A9 on Clang 11, and I'm seeing similar assembly as the reporter:

e.g.,

vld1.16>{d16[]-d17[]}, [r6 :16]
&
vld1.32 {d16[]-d17[]}, [r8 :32]

And that does implode at runtime (even the kernel fixup can't deal with it).

But, with GCC (tested w/ 7.5 & 10.3), I get no :align hints, and the CPU deals with it all on its loneseome:

vld1.32>{d16[]-d17[]}, [r5]
vld1.16>{d16[]-d17[]}, [r5]

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 14, 2021

gcc is usually "smart" enough to ignore casts using unnamed "temporary" variables. On the other hand clang thinks casts with unnamed variables are supposed to be explicit and as such doesn't ignore them. C standard itself doesn't allow unaligned named variables.

In later compiler versions using named "temporary" variables can cause compiler warnings if the variable scope extends past end of declaring function. This is pretty much only case I know when unnamed "temporary" variables must be used.

@NiLuJe
Copy link
Contributor

NiLuJe commented Apr 14, 2021

Most of this flies waaay too far above my head, just wanted to point out that the previous iteration "works" w/ current GCC versions (as long as the CPU actually handles unaligned accesses) ;).

@mtl1979
Copy link
Collaborator

mtl1979 commented Apr 14, 2021

There is quite a lot of workarounds for compilers that try to be too standards conforming or too smart... I've seen code that works correctly with optimizations enabled, but craps the shit out if optimizations are disabled.

Dead2 added a commit that referenced this issue May 8, 2021
- Include porting guide in release packages #917
- Documentation improvements #913 #949
- Added Windows ARM binaries in release packages #916
- Fix crash on ARMv7 #927
- Fix building on FreeBSD #921
- Fix building with musl on aarch64 #936
- Fix ARM float-abi detection #918
- Fix cmake detection of risc-v architectures #942
- Minor buildsystem fixes #922 #924 #933 #938 #950
- Improve zlib-compat build #915 #944
- CI/Test improvements #926 #929 #925 #937 #939 #940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants