Regex query with fatal signal 11 (SIGSEGV) error

Heisenberg :

I am using couchbase lite version android-ee:2.1.2. I stored some data in local couchbase lite database. Now, I am trying to query data from local couchbase lite database with the help of regex query like,

Query query = QueryBuilder
                .select(SelectResult.property("info"))
                .from(DataSource.database(localDatabase))
                .where(Expression.property("info").regex(Expression.string("^v" + "_" + "(4.6.2|1.7.7)" + "_" + "[123]" + "_" + "[12345678]")));

And my database looks like,

v_1.7.7_1_3
v_1.7.5_1_3
v_4.7.1_2_8
v_4.7.1_1_8
v_4.7.2_2_8
v_4.7.2_2_8
v_4.7.1_1_8
v_4.7.1_2_8
v_4.7.5_1_8
v_4.9.3_1_1
...
...
...
and so on many entries

To understand database structure let's take an example of v_1.7.7_1_3 here v can be defined as a just value, 1.7.7 is tag then 1 is parent class(this can be of type 1,2 and 3) and then 3 is child class(this can be of type 1,2,3,4,5,6,7 and 8).

Now user can select multiple tags, parent classes, and child classes as a choice. Then I have to query data from local couchbase lite according to parameters selected respectively. Currently, as I stated above I am trying to query data with the help of regex as like,

For example, let a user selected tag 4.6.2 and 1.7.7, then the parent classes are 1,2 and 3 and then child classes 1-8. So my query will be like,

"^v" + "_" + "(4.6.2|1.7.7)" + "_" + "[123]" + "_" + "[12345678]"

I already tried this query on https://regex101.com where it is working perfectly, but not with couchbase lite.

Although the application is just crashing with a fatal error,

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 25543 (.mains.activity)

Here some logs,

V/Query: Query encoded as {"WHAT":[[".info"]],"WHERE":["regexp_like()",[".info"],"^v_(4.6.2|1.7.7)_[123]_[12345678]"]}
I/LiteCore [Query]: {Query#3}==> N8litecore11SQLiteQueryE 0x7f5a2d9098
I/LiteCore [Query]: {Query#3} Compiling JSON query: {"WHAT":[[".info"]],"WHERE":["regexp_like()",[".info"],"^v_(4.6.2|1.7.7)_[123]_[12345678]"]}
I/LiteCore [Query]: {Query#3} Compiled as SELECT fl_result(fl_value(body, 'info')) FROM kv_default WHERE (regexp_like(fl_value(body, 'info'), '^v_(4.6.2|1.7.7)_[123]_[12345678]')) AND (flags & 1) = 0
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 28308 (.mains.activity)
Heisenberg :

After some hours of working and research on couchbase lite, I got this. First thing there is nothing wrong with regex query it is working fine.

And the second one is while checking my database I realized that info field on which I am querying data is EMPTY or NULL in some database entries. So I added a condition in my query like,

Expression.property("info").notNullOrMissing()

So when info is available then I am performing my regex query as like,

.where(Expression.property("info").notNullOrMissing().and(Expression.property("info").regex(Expression.string("^v" + "_" + "(4.6.2|1.7.7)" + "_" + "[123]" + "_" + "[12345678]"))))

And it is working perfectly without any fatal signal error or anything.

Note: - Another thing is that info field in my database is defined as index, so maybe I am querying data on index field and it is getting null or empty that's why I am getting a fatal signal error (I am still searching, is this logic correct or not.)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=153190&siteId=1