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

Xapian crash scenarios #3877

Closed
kelson42 opened this issue Jun 11, 2024 · 8 comments · Fixed by #3885
Closed

Xapian crash scenarios #3877

kelson42 opened this issue Jun 11, 2024 · 8 comments · Fixed by #3885
Assignees
Labels
Milestone

Comments

@kelson42
Copy link
Collaborator

We still have crashes in Xapian with Kiwix Android 3.11.0, here two traces:

== # 1 ==

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 17215 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0x00000000005a92cc  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #01  pc 0x00000000005a9bfc  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #02  pc 0x00000000005aba74  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #03  pc 0x000000000059b2dc  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #04  pc 0x0000000000591b38  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #05  pc 0x00000000005d5a14  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #06  pc 0x000000000057766c  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #07  pc 0x0000000000574f28  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+40)
  #08  pc 0x000000000057af7c  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #09  pc 0x0000000000574ec4  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Xapian::Query::Internal::postlist_sub_and_like(Xapian::Internal::AndContext&, QueryOptimiser*, double) const+40)
  #10  pc 0x000000000057a85c  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #11  pc 0x000000000057a774  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #12  pc 0x0000000000574f28  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+40)
  #13  pc 0x000000000057b1fc  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #14  pc 0x000000000057af7c  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #15  pc 0x00000000005d53c4  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #16  pc 0x00000000005d89a0  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk
  #17  pc 0x0000000000567db8  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Xapian::Enquire::Internal::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+632)
  #18  pc 0x0000000000569c70  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Xapian::Enquire::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+36)
  #19  pc 0x000000000022c494  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (zim::SuggestionSearch::getResults(int, int) const+132)
  #20  pc 0x000000000001c573  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/split_config.armeabi_v7a.apk (Java_org_kiwix_libzim_SuggestionSearch_getResults+106)
  #21  pc 0x00000000001293fb  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (org.kiwix.libzim.Search.getResults [DEDUPED]+82)
  #22  pc 0x000000000015d057  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (org.kiwix.kiwixmobile.core.search.viewmodel.SearchState.getVisibleResults+590)
  #23  pc 0x000000000041a575  /system/lib/libart.so (art_quick_invoke_stub_internal+68)
  #24  pc 0x00000000003f3b4b  /system/lib/libart.so (art_quick_invoke_stub+226)
  #25  pc 0x00000000000a1429  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+136)
  #26  pc 0x00000000001eb8f5  /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+232)
  #27  pc 0x00000000001e65d5  /system/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+776)
  #28  pc 0x00000000003f0bb3  /system/lib/libart.so (MterpInvokeVirtualQuick+422)
  #29  pc 0x0000000000411014  /system/lib/libart.so (ExecuteMterpImpl+29972)
  #30  pc 0x00000000000ca342  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.vdex
  #31  pc 0x00000000001caf4d  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool) (.llvm.28690422)+352)
  #32  pc 0x00000000001cf767  /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+82)
  #33  pc 0x00000000003e1fb3  /system/lib/libart.so (artQuickToInterpreterBridge+890)
  #34  pc 0x000000000041eaff  /system/lib/libart.so (art_quick_to_interpreter_bridge+30)
  #35  pc 0x0000000000335ba9  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith+152)
  #36  pc 0x000000000033797d  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (kotlinx.coroutines.DispatchedTask.run+1628)
  #37  pc 0x000000000038b287  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (kotlinx.coroutines.internal.LimitedDispatcher.run+118)
  #38  pc 0x000000000033804b  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (kotlinx.coroutines.scheduling.TaskImpl.run+58)
  #39  pc 0x000000000029df2f  /data/app/org.kiwix.kiwixmobile-QVD3CZ7BmIYkVSF-q_gj_Q==/oat/arm/base.odex (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run+2422)
  #40  pc 0x000000000041a575  /system/lib/libart.so (art_quick_invoke_stub_internal+68)
  #41  pc 0x00000000003f3b4b  /system/lib/libart.so (art_quick_invoke_stub+226)
  #42  pc 0x00000000000a1429  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+136)
  #43  pc 0x000000000035361d  /system/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+52)
  #44  pc 0x00000000003543a9  /system/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+316)
  #45  pc 0x0000000000375ae5  /system/lib/libart.so (art::Thread::CreateCallback(void*)+900)
  #46  pc 0x0000000000063af5  /system/lib/libc.so (__pthread_start(void*)+22)
  #47  pc 0x000000000001df95  /system/lib/libc.so (__start_thread+22)

== #2 ==



*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 3754 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0x0000000000606584  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #01  pc 0x0000000000606e3c  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #02  pc 0x0000000000608cb8  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #03  pc 0x00000000005f9ad4  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #04  pc 0x000000000062ec48  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #05  pc 0x00000000005d8f48  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #06  pc 0x00000000005d6ba4  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+28)
  #07  pc 0x00000000005dc798  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #08  pc 0x00000000005d6b48  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_and_like(Xapian::Internal::AndContext&, QueryOptimiser*, double) const+28)
  #09  pc 0x00000000005dc05c  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #10  pc 0x00000000005dbf58  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #11  pc 0x00000000005d6ba4  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+28)
  #12  pc 0x00000000005dca14  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #13  pc 0x00000000005dc798  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #14  pc 0x000000000062e748  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #15  pc 0x0000000000631cb4  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so
  #16  pc 0x00000000005cab88  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Enquire::Internal::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+504)
  #17  pc 0x000000000029edd4  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libzim.so (zim::SuggestionSearch::getResults(int, int) const+124)
  #18  pc 0x0000000000027148  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/split_config.arm64_v8a.apk!libzim_wrapper.so (Java_org_kiwix_libzim_SuggestionSearch_getResults+168) (BuildId: 6633925cfdce17aa0079498777317a589d32289b)
  #19  pc 0x0000000000355830  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144)
  #20  pc 0x00000000005ba6b0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016)
  #21  pc 0x000000000025f222  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/base.apk (org.kiwix.kiwixmobile.core.search.viewmodel.SearchState.getVisibleResults+90)
  #22  pc 0x00000000005ba654  /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
  #23  pc 0x000000000025d2cc  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/base.apk (org.kiwix.kiwixmobile.core.search.SearchFragment$render$2$1$searchResult$1.invokeSuspend+20)
  #24  pc 0x0000000002063530  /memfd:jit-cache (kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith+192)
  #25  pc 0x000000000203a474  /memfd:jit-cache (kotlinx.coroutines.DispatchedTask.run+1284)
  #26  pc 0x00000000005bb4d4  /apex/com.android.art/lib64/libart.so (nterp_helper+7636)
  #27  pc 0x000000000020f1a8  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/base.apk (kotlinx.coroutines.internal.LimitedDispatcher.run+24)
  #28  pc 0x00000000005bb474  /apex/com.android.art/lib64/libart.so (nterp_helper+7540)
  #29  pc 0x0000000000212240  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/base.apk (kotlinx.coroutines.scheduling.TaskImpl.run+4)
  #30  pc 0x00000000005bb474  /apex/com.android.art/lib64/libart.so (nterp_helper+7540)
  #31  pc 0x00000000002110cc  /data/app/~~ymEBKaJFR65gu_Ft6MB_hQ==/org.kiwix.kiwixmobile-bDIVAAsaFsXcIa3x-YMG9w==/base.apk (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run+156)
  #32  pc 0x000000000033eda4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
  #33  pc 0x0000000000239d54  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144)
  #34  pc 0x000000000053a1b0  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600)
  #35  pc 0x00000000000c14dc  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+204)
  #36  pc 0x0000000000054930  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
@kelson42 kelson42 added the bug label Jun 11, 2024
@kelson42 kelson42 added this to the 3.12.0 milestone Jun 11, 2024
@kelson42
Copy link
Collaborator Author

@mgautierfr Is that a bug in libzim or a handling one in Kiwix Android?

@kelson42 kelson42 modified the milestones: 3.12.0, 3.11.1 Jun 13, 2024
@MohitMaliFtechiz
Copy link
Collaborator

@mgautierfr There are some other crashes as well reported on the playStore related to Xapian.

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 31615 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0x00000000005a92cc  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #01  pc 0x00000000005a9bfc  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #02  pc 0x00000000005aba74  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #03  pc 0x000000000059b2dc  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #04  pc 0x0000000000591b38  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #05  pc 0x00000000005d5a14  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #06  pc 0x000000000057766c  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #07  pc 0x0000000000574f28  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+40)
  #08  pc 0x000000000057af7c  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #09  pc 0x0000000000574ec4  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_and_like(Xapian::Internal::AndContext&, QueryOptimiser*, double) const+40)
  #10  pc 0x000000000057a85c  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #11  pc 0x000000000057a774  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #12  pc 0x0000000000574f28  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so (Xapian::Query::Internal::postlist_sub_or_like(Xapian::Internal::OrContext&, QueryOptimiser*, double) const+40)
  #13  pc 0x000000000057b1fc  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #14  pc 0x000000000057af7c  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #15  pc 0x00000000005d53c4  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #16  pc 0x00000000005d89a0  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so
  #17  pc 0x0000000000567db8  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so (Xapian::Enquire::Internal::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+632)
  #18  pc 0x0000000000569c70  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libkiwix.so (Xapian::Enquire::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+36)
  #19  pc 0x000000000022c494  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libzim.so (zim::SuggestionSearch::getResults(int, int) const+132)
  #20  pc 0x000000000001c573  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/split_config.armeabi_v7a.apk!libzim_wrapper.so (Java_org_kiwix_libzim_SuggestionSearch_getResults+106) (BuildId: 156c0086f806093be1da1b1615c4232400f11639)
  #21  pc 0x000000000003c0fb  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.odex (art_jni_trampoline+82)
  #22  pc 0x0000000002052921  /memfd:/jit-cache (org.kiwix.kiwixmobile.core.search.viewmodel.SearchState.getVisibleResults+480)
  #23  pc 0x00000000000d7bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
  #24  pc 0x000000000042f147  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250)
  #25  pc 0x00000000000dffb7  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174)
  #26  pc 0x0000000000210be1  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+280)
  #27  pc 0x000000000020c523  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774)
  #28  pc 0x00000000004298db  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualQuick+518)
  #29  pc 0x00000000000d6594  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_quick+20)
  #30  pc 0x0000000000224520  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (org.kiwix.kiwixmobile.core.search.viewmodel.SearchViewModel$$ExternalSyntheticLambda0.subscribe+36)
  #31  pc 0x0000000000425b09  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432)
  #32  pc 0x00000000000d2a14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20)
  #33  pc 0x00000000001c5a04  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual+106)
  #34  pc 0x0000000000429b33  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualQuick+1118)
  #35  pc 0x00000000000d6594  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_quick+20)
  #36  pc 0x00000000001c2b46  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.Flowable.subscribe+4)
  #37  pc 0x0000000000429b33  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualQuick+1118)
  #38  pc 0x00000000000d6594  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_quick+20)
  #39  pc 0x00000000001c2ba6  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.Flowable.subscribe+12)
  #40  pc 0x0000000000425b09  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432)
  #41  pc 0x00000000000d2a14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20)
  #42  pc 0x00000000001c9da6  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run+24)
  #43  pc 0x0000000000425b09  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432)
  #44  pc 0x00000000000d2a14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20)
  #45  pc 0x00000000001cd77a  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.run+42)
  #46  pc 0x0000000000429b33  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualQuick+1118)
  #47  pc 0x00000000000d6594  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_quick+20)
  #48  pc 0x00000000001cd690  /data/app/org.kiwix.kiwixmobile-UnW6HgXnf80xedO_Bw0vaw==/oat/arm/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.call)
  #49  pc 0x00000000001ec45d  /apex/com.android.runtime/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.15413681340037344952)+192)
  #50  pc 0x00000000001f0c41  /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124)
  #51  pc 0x0000000000418cb9  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808)
  #52  pc 0x00000000000dc5a1  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32)
  #53  pc 0x000000000025317d  /system/framework/arm/boot.oat (java.util.concurrent.FutureTask.run+196)
  #54  pc 0x00000000002de8cf  /system/framework/arm/boot.oat (java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run+118)
  #55  pc 0x00000000002a8fcf  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor.runWorker+1014)
  #56  pc 0x00000000002a6c4f  /system/framework/arm/boot.oat (java.util.concurrent.ThreadPoolExecutor$Worker.run+54)
  #57  pc 0x0000000000183749  /system/framework/arm/boot.oat (java.lang.Thread.run+64)
  #58  pc 0x00000000000d7bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
  #59  pc 0x000000000042f147  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250)
  #60  pc 0x00000000000dffb7  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174)
  #61  pc 0x0000000000370c5f  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54)
  #62  pc 0x0000000000371951  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+304)
  #63  pc 0x00000000003a28e7  /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+978)
  #64  pc 0x00000000000a75b3  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20)
  #65  pc 0x0000000000061b33  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 11518 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0x0000000000859c78  /vendor/lib64/egl/libGLES_mali.so (vulkan::debug_utils::trigger_address_binding_event(vulkan::device const&, vulkan::object const*, unsigned long, unsigned long, vulkan::debug_utils::binding_type)+24)
  #01  pc 0x0000000000868844  /vendor/lib64/egl/libGLES_mali.so (vulkan::image::~image()+52)
  #02  pc 0x00000000005c0330  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Database::get_doccount() const+48)
  #03  pc 0x00000000005caa34  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/split_config.arm64_v8a.apk!libkiwix.so (Xapian::Enquire::Internal::get_mset(unsigned int, unsigned int, unsigned int, Xapian::RSet const*, Xapian::MatchDecider const*) const+164)
  #04  pc 0x000000000029edd4  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/split_config.arm64_v8a.apk!libzim.so (zim::SuggestionSearch::getResults(int, int) const+124)
  #05  pc 0x0000000000027148  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/split_config.arm64_v8a.apk!libzim_wrapper.so (Java_org_kiwix_libzim_SuggestionSearch_getResults+168) (BuildId: 6633925cfdce17aa0079498777317a589d32289b)
  #06  pc 0x000000000002ce64  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/oat/arm64/base.odex (art_jni_trampoline+116)
  #07  pc 0x00000000005b9a30  /apex/com.android.art/lib64/libart.so (nterp_helper+4016)
  #08  pc 0x000000000025f222  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/base.apk (org.kiwix.kiwixmobile.core.search.viewmodel.SearchState.getVisibleResults+90)
  #09  pc 0x00000000005b99d4  /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
  #10  pc 0x000000000025d2cc  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/base.apk (org.kiwix.kiwixmobile.core.search.SearchFragment$render$2$1$searchResult$1.invokeSuspend+20)
  #11  pc 0x00000000020428c0  /memfd:jit-cache (kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith+176)
  #12  pc 0x0000000002027648  /memfd:jit-cache (kotlinx.coroutines.DispatchedTask.run+1208)
  #13  pc 0x00000000005ba854  /apex/com.android.art/lib64/libart.so (nterp_helper+7636)
  #14  pc 0x000000000020f1a8  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/base.apk (kotlinx.coroutines.internal.LimitedDispatcher.run+24)
  #15  pc 0x00000000005ba7f4  /apex/com.android.art/lib64/libart.so (nterp_helper+7540)
  #16  pc 0x0000000000212240  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/base.apk (kotlinx.coroutines.scheduling.TaskImpl.run+4)
  #17  pc 0x00000000005ba7f4  /apex/com.android.art/lib64/libart.so (nterp_helper+7540)
  #18  pc 0x00000000002110cc  /data/app/~~bB4-q8oRKOQpMyCD-suDdw==/org.kiwix.kiwixmobile-LEfhWv-T0kGNkBWOyRmYpA==/base.apk (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run+156)
  #19  pc 0x000000000033b3a4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
  #20  pc 0x000000000023a5d0  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144)
  #21  pc 0x0000000000539bf4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600)
  #22  pc 0x00000000005395a4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallbackWithUffdGc(void*)+8)
  #23  pc 0x00000000000ca7cc  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+204)
  #24  pc 0x00000000000607b0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

All the crashes are happening while accessing this method zim::SuggestionSearch::getResults, can we catch the exception here on this method if there is any error that occurred due to any reason? So that it can be caught on the android side, and handle the crash.

@mgautierfr
Copy link
Member

Is that a bug in libzim or a handling one in Kiwix Android?

I don't know.

Exception thrown by Xapian should be catch by libzim and handle there (by fallback to binary search in titles)

But the last callstack posted by @MohitMaliFtechiz is strange.
It goes from Xapian::Database::get_doccount() to vulkan::image::~image(). It may be a clue that the callstack is broken.

Did we have such kind of bug with previous version or it is only 3.11.0 ?
Do we have a reproducer or it is just crash reported on the play store ?

@MohitMaliFtechiz
Copy link
Collaborator

But the last callstack posted by @MohitMaliFtechiz is strange.
It goes from Xapian::Database::get_doccount() to vulkan::image::~image(). It may be a clue that the callstack is broken.
Did we have such kind of bug with previous version or it is only 3.11.0 ?

@mgautierfr We had this type of bug when we were trying to access the results via zim::SuggestionSearch::getResults frequently to get the new result on behalf of new search term(by canceling the previous one and asking for the result to libzim again). There were several issues #3679, #3581, #3556. We had placed fixes for those issues to stabilize the search issue on the Android side and those fixes worked. As you can see playStore reported 1-1 crashes on different devices.

Screenshot from 2024-06-14 11-35-09

Do we have a reproducer or it is just crash reported on the play store ?

For now, it is a crash reported by the playStore. But this issue occurs when we cancel the previous result and ask for the new result set from libzim.

As far as I think after seeing the behavior, the callstack is broken due to when we are canceling the previous call and asking for a new result from libzim, at this moment, code has been executed to fetch the result from libzim, and we canceled that operation. But libzim is trying to get the result for that call so that's why it is throwing the error.

One more thing here we need to know is that getting the result from libzim is performing on the IO thread to not block the Android UI.

Can we catch this type of exception at the libzim level? so that we can prevent this type of errors?

@mgautierfr
Copy link
Member

One more thing here we need to know is that getting the result from libzim is performing on the IO thread to not block the Android UI.

Are you running different IO thread in the same time ?
All search API is not thread safe. All calls must be made from the same thread (or be protected with a global mutex)

Can we catch this type of exception at the libzim level? so that we can prevent this type of errors?

Which kind of exception ? Not all crashed are caused by exception. Invalid read (SIGSEGV) or call stack corruption (as because of data race) make the app crash without exception (as any C code which can crash without exception)

@kelson42
Copy link
Collaborator Author

kelson42 commented Jun 15, 2024

One more thing here we need to know is that getting the result from libzim is performing on the IO thread to not block the Android UI.

Are you running different IO thread in the same time ? All search API is not thread safe. All calls must be made from the same thread (or be protected with a global mutex)

This has been discussed and fixed in the past... but this is the most probable scenario. @MohitMaliFtechiz Can you check again please that you never do two (or more) requests (or request result treatments) at the same time?

From what I see (it seems new custom apps are impacted as well), a regression has been built in around the suggestion system in the latest version 3.11.

@MohitMaliFtechiz
Copy link
Collaborator

MohitMaliFtechiz commented Jun 19, 2024

Are you running different IO thread in the same time ?
All search API is not thread safe. All calls must be made from the same thread (or be protected with a global mutex)

@mgautierfr Yes, we are using the Coroutine that manages the call on the IO thread, and we are using the global mutex for this.

searchMutex.withLock {
// `cancelAndJoin` cancels the previous running job and waits for it to completely cancel.
renderingJob?.cancelAndJoin()
isDataLoading = false
searchInTextMenuItem?.actionView?.isVisible = state.searchOrigin == FromWebView
setIsPageSearchEnabled(state.searchTerm.isNotBlank())
fragmentSearchBinding?.searchLoadingIndicator?.isShowing(true)
renderingJob = searchViewModel.viewModelScope.launch(Dispatchers.Main) {
val searchResult = withContext(Dispatchers.IO) {
state.getVisibleResults(0, renderingJob)
}
fragmentSearchBinding?.searchLoadingIndicator?.isShowing(false)
searchResult?.let {
fragmentSearchBinding?.searchNoResults?.isVisible = it.isEmpty()
searchAdapter?.items = it
}
}
}
}

Invalid read (SIGSEGV) or call stack corruption (as because of data race) make the app crash without exception (as any C code which can crash without exception)

@mgautierfr Okay, so here the crash was happening due to the call stack being corrupted. (in a very special condition since there is a very limited crash shown on the playStore). There was an issue with the mutex call site(we were doing that in the fragment and most of the things were handled by that mutex, but in a very special condition this issue was occurring). I have placed a fix for it in #3885 to avoid accessing the data from libzim with multiple places. Also, added the instrumentation and unit test cases for testing this functionality.

Exception thrown by Xapian should be catch by libzim and handle there (by fallback to binary search in titles)

We are currently using the libzim 9.2.1-1, in that version of libzim, are these exceptions handled?

@kelson42
Copy link
Collaborator Author

Exception thrown by Xapian should be catch by libzim and handle there (by fallback to binary search in titles)

We are currently using the libzim 9.2.1-1, in that version of libzim, are these exceptions handled?

Yes, we use anyway the latest version of libzim, but of course exceptions should be caught in Kiwix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants