Describe the bug
PlayStore reported this native crash for kiwix-app, and some custom apps as well e.g. wikivoyage, wikimed, etc. There are some occurrence in all these applications.
Expected behavior
It should not crash the application.
15 pc 0x0000000000428f2d /apex/com.android.art/lib/libart.so (art::JNI::CallNonvirtualVoidMethodA(_JNIEnv, _jobject, _jclass, _jmethodID, jvalue const*)+500)
16 pc 0x0000000000417bb1 /apex/com.android.art/lib/libart.so (art::JNI::NewObjectA(_JNIEnv, _jclass, _jmethodID, jvalue const)+192)
17 pc 0x00000000004118a9 /apex/com.android.art/lib/libart.so (art::ThrowNewException(_JNIEnv, _jclass, char const, _jobject)+144)
18 pc 0x0000000000016871 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/base.apk!libzim_wrapper.so (Java_org_kiwix_libzim_Item_getData+564) (BuildId: 156c0086f806093be1da1b1615c4232400f11639)
19 pc 0x000000000009ccfd /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (art_jni_trampoline+68)
20 pc 0x00000000002273c9 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (org.kiwix.kiwixmobile.core.reader.ZimFileReader$$ExternalSyntheticLambda0.run+680)
21 pc 0x000000000020e9bf /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.operators.completable.CompletableFromAction.subscribeActual+222)
22 pc 0x0000000000174101 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.Completable.subscribe+48)
23 pc 0x000000000020ec69 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run+64)
24 pc 0x000000000020cb85 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.Scheduler$DisposeTask.run+84)
25 pc 0x00000000002101a1 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.run+360)
26 pc 0x000000000020f987 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.call+38)
27 pc 0x00000000004c4dbb /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.FutureTask.run+178)
28 pc 0x000000000054e66f /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run+118)
29 pc 0x0000000000517625 /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+828)
30 pc 0x0000000000514bdf /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+62)
31 pc 0x00000000003f0ebf /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.lang.Thread.run+70)
32 pc 0x00000000001441d5 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68)
Describe the bug PlayStore reported this native crash for kiwix-app, and some custom apps as well e.g. wikivoyage, wikimed, etc. There are some occurrence in all these applications.
Expected behavior It should not crash the application.
Steps to reproduce the behavior: No reproducing steps are available. But, we have a PR https://github.com/kiwix/kiwix-android/pull/3937 where @CalebKL facing this issue when we are creating the new zimFileReader with a different zimFile(see https://github.com/kiwix/kiwix-android/issues/3937#issuecomment-2236153494). This issue is occurring here https://github.com/kiwix/kiwix-android/blob/7dcf0424cef46a811b2c33902babf00797a61aed/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt#L365, when we are writing the content to pipe.
Environment
Logs
backtrace:
00 pc 0x0000000000063126 /apex/com.android.runtime/lib/bionic/libc.so (abort+138)
01 pc 0x0000000000013e8d /apex/com.android.os.statsd/lib/libstatssocket.so (abort_message+104)
02 pc 0x00000000000147b3 /apex/com.android.os.statsd/lib/libstatssocket.so (demangling_terminate_handler()+130)
03 pc 0x0000000000014677 /apex/com.android.os.statsd/lib/libstatssocket.so (std::__terminate(void (*)())+2)
04 pc 0x0000000000014015 /apex/com.android.os.statsd/lib/libstatssocket.so (__cxxabiv1::failed_throw(cxxabiv1::cxa_exception*)+12)
05 pc 0x0000000000013fa1 /apex/com.android.os.statsd/lib/libstatssocket.so (__cxa_throw+72)
06 pc 0x00000000000160e1 /apex/com.android.os.statsd/lib/libstatssocket.so (operator new(unsigned int)+52)
07 pc 0x00000000001ed3a9 /apex/com.android.art/lib/libart.so (art::Thread::CreateInternalStackTrace(art::ScopedObjectAccessAlreadyRunnable const&) const+32)
08 pc 0x00000000004b7859 /apex/com.android.art/lib/libart.so (art::Throwable_nativeFillInStackTrace(_JNIEnv, _jclass) (.__uniq.282764230813858432628848516352795405182)+28)
09 pc 0x0000000000327773 /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (art_jni_trampoline+42)
10 pc 0x00000000003f3fff /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.lang.Throwable.fillInStackTrace+86)
11 pc 0x0000000000475685 /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat ([DEDUPED] ?.+124)
12 pc 0x00000000001441d5 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68)
13 pc 0x0000000000143c0f /apex/com.android.art/lib/libart.so (art_quick_invoke_stub+256)
14 pc 0x00000000002738bb /apex/com.android.art/lib/libart.so (art::JValue art::InvokeWithJValues<art::ArtMethod>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject, art::ArtMethod, jvalue const)+546)
15 pc 0x0000000000428f2d /apex/com.android.art/lib/libart.so (art::JNI::CallNonvirtualVoidMethodA(_JNIEnv, _jobject, _jclass, _jmethodID, jvalue const*)+500)
16 pc 0x0000000000417bb1 /apex/com.android.art/lib/libart.so (art::JNI::NewObjectA(_JNIEnv, _jclass, _jmethodID, jvalue const)+192)
17 pc 0x00000000004118a9 /apex/com.android.art/lib/libart.so (art::ThrowNewException(_JNIEnv, _jclass, char const, _jobject)+144)
18 pc 0x0000000000016871 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/base.apk!libzim_wrapper.so (Java_org_kiwix_libzim_Item_getData+564) (BuildId: 156c0086f806093be1da1b1615c4232400f11639)
19 pc 0x000000000009ccfd /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (art_jni_trampoline+68)
20 pc 0x00000000002273c9 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (org.kiwix.kiwixmobile.core.reader.ZimFileReader$$ExternalSyntheticLambda0.run+680)
21 pc 0x000000000020e9bf /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.operators.completable.CompletableFromAction.subscribeActual+222)
22 pc 0x0000000000174101 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.Completable.subscribe+48)
23 pc 0x000000000020ec69 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run+64)
24 pc 0x000000000020cb85 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.Scheduler$DisposeTask.run+84)
25 pc 0x00000000002101a1 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.run+360)
26 pc 0x000000000020f987 /data/app/~~6XGCYiWOUmxEpYdHCqew9w==/org.kiwix.kiwixcustomwikimed-k7w1oehgWtmf_-uGR22Rag==/oat/arm/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.call+38)
27 pc 0x00000000004c4dbb /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.FutureTask.run+178)
28 pc 0x000000000054e66f /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run+118)
29 pc 0x0000000000517625 /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+828)
30 pc 0x0000000000514bdf /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+62)
31 pc 0x00000000003f0ebf /data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat (java.lang.Thread.run+70)
32 pc 0x00000000001441d5 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68)
33 pc 0x00000000001bc28b /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread, unsigned int, unsigned int, art::JValue, char const)+466)
34 pc 0x0000000000235faf /apex/com.android.art/lib/libart.so (art::Thread::CreateCallback(void*)+2070)
35 pc 0x00000000000ae253 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40)
36 pc 0x0000000000064123 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30)