Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-2077

Crash on fulltext search when using asterisk *

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      SDK and version

      SDK : React-Native
      Version:
      "realm": "^12.6.2",
      "@realm/react": "^0.6.2",

      Observations

      • How frequent do the crash occur?
        • Every time I tippe the word "sinai"
      • Does it happen in production or during dev/test?
        • dev for sure. Didn't test prod. Only iOS. Android works well.
      • Can the crash be reproduced by you?
        • Yes, every time!
      • Can you provide instructions for how we can reproduce it?
        • Yes, see below!

      Crash log / stacktrace

      /Users/runner/work/realm-js/realm-js/packages/realm/bindgen/vendor/realm-core/src/realm/index_string.cpp:726: [realm-core-13.26.0] Assertion failed: end == pos + 1
      0   gls                                 0x00000001016dcb78 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
      1   gls                                 0x00000001016dcaf4 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 396
      2   gls                                 0x00000001016dc968 _ZN5realm4util19terminate_with_infoEPKcS2_lS2_OSt16initializer_listINS0_9PrintableEE + 0
      3   gls                                 0x00000001015edb90 _ZNK5realm10IndexArray29_index_string_find_all_prefixERNSt3__13setIxNS1_4lessIxEENS1_9allocatorIxEEEENS_10StringDataEPKc + 1848
      4   gls                                 0x00000001015f1e1c _ZNK5realm11StringIndex17find_all_fulltextERNSt3__16vectorINS_6ObjKeyENS1_9allocatorIS3_EEEENS_10StringDataE + 256
      5   gls                                 0x000000010166afb0 _ZN5realm18StringNodeFulltext18_search_index_initEv + 172
      6   gls                                 0x00000001016667d8 _ZN5realm6OrNode4initEb + 236
      7   gls                                 0x000000010163e68c _ZNK5realm5Query4initEv + 76
      8   gls                                 0x000000010163e850 _ZNK5realm5Query11do_find_allERNS_14QueryStateBaseE + 244
      9   gls                                 0x00000001016a677c _ZN5realm9TableView7do_syncEv + 556
      10  gls                                 0x00000001013c7fd4 _ZN5realm5_impl15ResultsNotifier3runEv + 888
      11  gls                                 0x00000001013c204c _ZN5realm5_impl16RealmCoordinator19run_async_notifiersEv + 1128
      12  gls                                 0x00000001013c1b80 _ZN5realm5_impl16RealmCoordinator9on_changeEv + 68
      13  gls                                 0x000000010139eb34 _ZN5realm5_impl20ExternalCommitHelper6listenEv + 204
      14  gls                                 0x000000010139ec58 _ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS8_16RealmCoordinatorERKNS7_11RealmConfigEE3$_0EEEEEPvSH_ + 56
      15  libsystem_pthread.dylib             0x0000000104a33414 _pthread_start + 104
      16  libsystem_pthread.dylib             0x0000000104a2e5e0 thread_start + 8
      !!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose
      

      Steps & Code to Reproduce

      1. Load my bundle-realm file.
      2. Use the following schema:
      import Realm, { BSON, ObjectSchema } from "realm";
      
      export class Song extends Realm.Object<Song> {
      	_id!: BSON.ObjectId;
      	title!: string;
      	number!: string;
      	melody?:string;
      	bibleVers?: string;
      	footnote?: string;
      	verses!: Vers[];
      	static schema: ObjectSchema = {
      		name: "Song",
      		properties: {
      			_id: "objectId",
      			title: { type: "string", indexed: "full-text" },
      			number: { type: "string", indexed: true },
      			melody: { type: "string", indexed: "full-text",  optional: true, },
      			bibleVers: { type: "string", indexed: "full-text", optional: true, },
      			footnote: { type: "string", indexed: "full-text",  optional: true, },
      			verses: "Vers[]"
      		},
      		primaryKey: "_id",
      	};
      }
      
      
      export class Vers extends Realm.Object<Vers> {
      	_id!: BSON.ObjectId;
      	isChorus!: boolean;
      	number?: string;
      	text!: string;
      	explanation?: string;
      	static schema: ObjectSchema = {
      		name: "Vers",
      		properties: {
      			_id: "objectId",
      			isChorus: { type: "bool", },
      			number: { type: "string", optional: true, },
      			text: { type: "string", indexed: "full-text" },
      			explanation: { type: "string",  optional: true, },
      			song: {
      				type: 'linkingObjects',
      				objectType: 'Song',
      				property: 'verses',
      			},
      		},
      		primaryKey: "_id",
      	};
      }
      
      1. Load realm provider in app root file:
        {{<RealmProvider schema= {[Song, Vers]}

        path="bundle.realm">}}

      2. Run this query somewhere:
      const searchText = "sinai";
      const sortedSongs = useQuery(Song, (songs) => {
      	if (searchText.length > 0) {
      		return songs.filtered(
      			"title TEXT $0 || verses.text TEXT $0",
      			`${searchText.trim()}*`,
      		);
      	}
      	return songs;
      }, [searchText]);
      
      

      Additional info:
      It dosent mater what you are searching for. You can search for exactly 4 chars like: "1234_" but as soon as you search for 5 or more chars like: "12345_" it crashes! But you can search for something like: "123467 1234567*". So it crashes only if its the first token and you have more then 4 chars in you search token.

      bundle.realm.zip

            Assignee:
            jorgen.edelbo@mongodb.com Jørgen Edelbo
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: