realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
963 stars 61 forks source link

[librealmc.so] array_direct.hpp - realm::IndexArray::_index_string_find_all_prefix #1588

Open ChrisKruegerDev opened 11 months ago

ChrisKruegerDev commented 11 months ago

How frequently does the bug occur?

Sometimes

Description

We are seeing the following crashes reported on our Android App (distributed via Play Store).

Stacktrace & log output

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 17767 >>> com.moviebase <<<

backtrace:
  #00  pc 0x00000000005b61a0  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::IndexArray::_index_string_find_all_prefix(std::__ndk1::set<long, std::__ndk1::less<long>, std::__ndk1::allocator<long>>&, realm::StringData, char const*) const+176) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #01  pc 0x00000000005b6358  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::IndexArray::_index_string_find_all_prefix(std::__ndk1::set<long, std::__ndk1::less<long>, std::__ndk1::allocator<long>>&, realm::StringData, char const*) const+699) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #02  pc 0x00000000005b9cc4  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::StringIndex::find_all_fulltext(std::__ndk1::vector<realm::ObjKey, std::__ndk1::allocator<realm::ObjKey>>&, realm::StringData) const+88) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #03  pc 0x00000000005f9748  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::StringNodeFulltext::_search_index_init()+495) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #04  pc 0x0000000000532094  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::BoolNode<realm::Equal>::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #05  pc 0x0000000000538ad0  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::IntegerNode<realm::ArrayInteger, realm::Equal>::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #06  pc 0x00000000005fa348  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::ExpressionNode::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #07  pc 0x00000000005fa348  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::ExpressionNode::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #08  pc 0x0000000000524344  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::Query::init() const+1760) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #09  pc 0x00000000005244e8  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::Query::do_find_all(realm::QueryStateBase&) const+1288) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #10  pc 0x00000000006255a4  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::TableView::do_sync()+484) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #11  pc 0x00000000003b04f8  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::_impl::ResultsNotifier::run()+182) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #12  pc 0x00000000003aad78  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::_impl::RealmCoordinator::run_async_notifiers()+1011) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #13  pc 0x00000000003aa944  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (realm::_impl::RealmCoordinator::on_change()+875) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #14  pc 0x0000000000412b3c  /data/app/~~qw2QM8GVi8D4kDpNqpb8dw==/com.moviebase-X0_GN51lL904QAFk2NufCw==/lib/arm64/librealmc.so (void* std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct>>, (anonymous namespace)::DaemonThread::DaemonThread()::$_0>>(void*)+277) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #15  pc 0x00000000000b6668  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
  #16  pc 0x00000000000532cc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

Can you reproduce the bug?

No

Reproduction Steps

We started to use the search query in Realm, where the user can enter a search with limited characters to ^A-Za-z0-9. Example:

// realm object
   @FullText
   var title: String? = null 

// realm query example
  query("title TEXT scifi*")

Version

1.12.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 10 - 14

Build environment

No response

cmelchior commented 11 months ago

Hi @chrisnkrueger Thank you for reporting this. Do you have the full stack trace? At least the part saying exactly what error is happening seems to be missing.

ChrisKruegerDev commented 11 months ago

@cmelchior Thanks for the fast reply. Unfortunately, the reports on the Google Play Console are limited. However, here is another error, which might be related:


*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 8226 >>> com.moviebase <<<

backtrace:
  #00  pc 0x000000000007da34  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168)
  #01  pc 0x0000000000665d6c  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (please_report_this_issue_in_github_realm_realm_core_v_13_23_2+65) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #02  pc 0x0000000000666044  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::util::terminate_internal(std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>&)+143) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #03  pc 0x0000000000665f0c  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::util::terminate_with_info(char const*, char const*, long, char const*, std::initializer_list<realm::util::Printable>&&)+162) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #04  pc 0x0000000000665d7c  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&)+149) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #05  pc 0x000000000033d610  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (void realm::util::terminate<unsigned long, long, unsigned long, unsigned long>(char const*, char const*, long, unsigned long, long, unsigned long, unsigned long)+45) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #06  pc 0x0000000000380c80  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::Allocator::translate(unsigned long) const+580) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #07  pc 0x00000000005b6160  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::IndexArray::_index_string_find_all_prefix(std::__ndk1::set<long, std::__ndk1::less<long>, std::__ndk1::allocator<long>>&, realm::StringData, char const*) const+684) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #08  pc 0x00000000005b6358  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::IndexArray::_index_string_find_all_prefix(std::__ndk1::set<long, std::__ndk1::less<long>, std::__ndk1::allocator<long>>&, realm::StringData, char const*) const+699) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #09  pc 0x00000000005b9cc4  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::StringIndex::find_all_fulltext(std::__ndk1::vector<realm::ObjKey, std::__ndk1::allocator<realm::ObjKey>>&, realm::StringData) const+88) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #10  pc 0x00000000005f9748  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::StringNodeFulltext::_search_index_init()+495) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #11  pc 0x0000000000532094  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::BoolNode<realm::Equal>::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #12  pc 0x0000000000538ad0  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::IntegerNode<realm::ArrayInteger, realm::Equal>::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #13  pc 0x00000000005fa348  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::ExpressionNode::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #14  pc 0x00000000005fa348  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::ExpressionNode::init(bool)+153) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #15  pc 0x0000000000524344  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::Query::init() const+1760) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #16  pc 0x00000000005244e8  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::Query::do_find_all(realm::QueryStateBase&) const+1288) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #17  pc 0x00000000006255a4  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::TableView::do_sync()+484) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #18  pc 0x00000000003b04f8  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::_impl::ResultsNotifier::run()+182) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #19  pc 0x00000000003aad78  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::_impl::RealmCoordinator::run_async_notifiers()+1011) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #20  pc 0x00000000003aa944  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (realm::_impl::RealmCoordinator::on_change()+875) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #21  pc 0x0000000000412b3c  /data/app/~~4337cjUxM4Y1UnUQCqf0qw==/com.moviebase-hfMBWHqbEAfAIdS4vktabw==/lib/arm64/librealmc.so (void* std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct>>, (anonymous namespace)::DaemonThread::DaemonThread()::$_0>>(void*)+277) (BuildId: aa6e02b9a2f0043624262102d3146bd74c01dd87)
  #22  pc 0x00000000000e5a08  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
  #23  pc 0x000000000007f27c  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)

Edit: Does the Realm query in Kotlin support the asterisk for the search? I am getting the following error message: java.lang.IllegalArgumentException: [RLM_ERR_INVALID_QUERY_STRING]: Invalid predicate: 'title TEXT s*': syntax error, unexpected '*', expecting end of file

clementetb commented 11 months ago

Hi @chrisnkrueger Token prefix search like the example you show is supported. We are investigating what might be the cause for the crash.

clementetb commented 11 months ago

Hi @chrisnkrueger the issue is that the query string is malformed, any string parameter must be within apostrophes ('):"

Try with query("title TEXT 'scifi*'")

clementetb commented 11 months ago

Hi again @chrisnkrueger , if you don't want to use apostrophes you can pass the string as a parameter as shown in the documentation examples.

By the way, are you able to reproduce the first crash? Do you have the sample data to reproduce it?

ChrisKruegerDev commented 8 months ago

@cmelchior I can reproduce the crash when I use the filter argument title TEXT 'u53346y5x*' (I can send you the 2mb ralm database).

Unfortunately, I don't get the correct stacktrace from the crash dump when using ndk-stack.