/ Check-in [83c467d7]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix further problems with fts5 handling corrupt databases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 83c467d7af63bd2e7800aff4fe9b09dbd75557460b75a9e07205dfae7e28312c
User & Date: dan 2019-01-10 15:17:32
Context
2019-01-10
17:08
Avoid use-after-free and double-free errors that could occur if an fts5 table is modified in certain ways while there are active cursors. check-in: 3291b2a6 user: dan tags: trunk
15:17
Fix further problems with fts5 handling corrupt databases. check-in: 83c467d7 user: dan tags: trunk
14:33
More aggressive early detection of orphaned and malformed autoindexes when parsing the schema. check-in: 10f9e39d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_index.c.

  6419   6419         iOff = iPgidxPrev;
  6420   6420   
  6421   6421         if( iPgidxOff<n ){
  6422   6422           fts5GetVarint32(&a[iPgidxOff], nByte);
  6423   6423           iEnd = iPgidxPrev + nByte;
  6424   6424         }else{
  6425   6425           iEnd = szLeaf;
         6426  +      }
         6427  +      if( iEnd>szLeaf ){
         6428  +        rc = FTS5_CORRUPT;
         6429  +        goto decode_out;
  6426   6430         }
  6427   6431   
  6428   6432         if( bFirst==0 ){
  6429   6433           iOff += fts5GetVarint32(&a[iOff], nByte);
  6430   6434           if( nByte>term.n ){
  6431   6435             rc = FTS5_CORRUPT;
  6432   6436             goto decode_out;

Changes to ext/fts5/fts5_vocab.c.

   517    517               break;
   518    518   
   519    519             case FTS5_VOCAB_COL:
   520    520               if( eDetail==FTS5_DETAIL_FULL ){
   521    521                 int iCol = -1;
   522    522                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){
   523    523                   int ii = FTS5_POS2COLUMN(iPos);
   524         -                pCsr->aCnt[ii]++;
   525    524                   if( iCol!=ii ){
   526    525                     if( ii>=nCol ){
   527    526                       rc = FTS5_CORRUPT;
   528    527                       break;
   529    528                     }
   530    529                     pCsr->aDoc[ii]++;
   531    530                     iCol = ii;
   532    531                   }
          532  +                pCsr->aCnt[ii]++;
   533    533                 }
   534    534               }else if( eDetail==FTS5_DETAIL_COLUMNS ){
   535    535                 while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){
   536    536                   assert_nc( iPos>=0 && iPos<nCol );
   537    537                   if( iPos>=nCol ){
   538    538                     rc = FTS5_CORRUPT;
   539    539                     break;

Changes to ext/fts5/test/fts5corrupt3.test.

  3162   3162   | end crash-e2d47e0624a42c.db
  3163   3163   }]} {}
  3164   3164   
  3165   3165   do_catchsql_test 28.1 {
  3166   3166     SELECT count( fts5_decode(id, block) ) FROM t2_data;
  3167   3167   } {1 {database disk image is malformed}}
  3168   3168   
         3169  +#-------------------------------------------------------------------------
         3170  +reset_db
         3171  +do_test 29.0 {
         3172  +  sqlite3 db {}
         3173  +  db deserialize [decode_hexdb {
         3174  +| size 28672 pagesize 4096 filename crash-e114c036e13dde.db
         3175  +| page 1 offset 0
         3176  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3177  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         3178  +|     32: 00 00 00 02 00 00 00 01 00 00 00 08 00 00 00 04   ................
         3179  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3180  +|     96: 00 00 00 00 0d 0f c7 00 06 0d b6 00 0f 8d 0f 36   ...............6
         3181  +|    112: 0e cb 0e 6b 0e 0e 0d b6 0d b6 00 00 00 00 00 00   ...k............
         3182  +|   3504: 00 00 00 00 00 00 56 07 06 17 1f 1f 01 7d 74 61   ......V.......ta
         3183  +|   3520: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         3184  +|   3536: 6f 6e 66 69 67 07 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         3185  +|   3552: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         3186  +|   3568: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         3187  +|   3584: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 06    WITHOUT ROWID[.
         3188  +|   3600: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         3189  +|   3616: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         3190  +|   3632: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         3191  +|   3648: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         3192  +|   3664: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         3193  +|   3680: 59 2c 20 73 7a 20 42 4c 4f 42 29 5e 05 07 17 21   Y, sz BLOB)^...!
         3194  +|   3696: 21 01 81 07 74 61 62 6c 65 74 31 5f 63 6f 6e 74   !...tablet1_cont
         3195  +|   3712: 65 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 05 43 52   entt1_content.CR
         3196  +|   3728: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63   EATE TABLE 't1_c
         3197  +|   3744: 6f 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47   ontent'(id INTEG
         3198  +|   3760: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   ER PRIMARY KEY, 
         3199  +|   3776: 63 30 2c 20 63 31 2c 20 63 32 29 69 04 07 17 19   c0, c1, c2)i....
         3200  +|   3792: 19 01 81 2d 74 61 62 6c 65 74 31 5f 69 64 78 74   ...-tablet1_idxt
         3201  +|   3808: 31 5f 69 64 78 04 43 52 45 41 54 45 20 54 41 42   1_idx.CREATE TAB
         3202  +|   3824: 4c 45 20 27 74 31 5f 69 64 78 27 28 73 65 67 69   LE 't1_idx'(segi
         3203  +|   3840: 64 2c 20 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50   d, term, pgno, P
         3204  +|   3856: 52 49 4d 41 52 59 20 4b 45 59 28 73 65 67 69 64   RIMARY KEY(segid
         3205  +|   3872: 2c 20 74 65 72 6d 29 29 20 57 49 54 48 4f 55 54   , term)) WITHOUT
         3206  +|   3888: 20 52 4f 57 49 44 55 03 07 17 1b 1b 01 81 01 74    ROWIDU........t
         3207  +|   3904: 61 62 6c 65 74 31 5f 64 61 74 61 74 31 5f 64 61   ablet1_datat1_da
         3208  +|   3920: 74 61 03 43 52 45 41 54 45 20 54 41 42 4c 45 20   ta.CREATE TABLE 
         3209  +|   3936: 27 74 31 5f 64 61 74 61 27 28 69 64 20 49 4e 54   't1_data'(id INT
         3210  +|   3952: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59   EGER PRIMARY KEY
         3211  +|   3968: 2c 20 62 6c 6f 63 6b 20 42 4c 4f 42 29 38 02 06   , block BLOB)8..
         3212  +|   3984: 17 11 11 08 5f 74 61 62 6c 65 74 31 74 31 43 52   ...._tablet1t1CR
         3213  +|   4000: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42   EATE VIRTUAL TAB
         3214  +|   4016: 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74 73 35   LE t1 USING fts5
         3215  +|   4032: 28 61 2c 62 2c 63 29 00 00 00 39 00 00 00 00 00   (a,b,c)...9.....
         3216  +| page 3 offset 8192
         3217  +|      0: 0d 00 00 00 03 0c af 00 0f e6 0f ef 0c af 00 00   ................
         3218  +|   3232: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86   ................
         3219  +|   3248: 2f 84 80 80 80 80 01 04 00 8c 62 00 00 03 12 02   /.........b.....
         3220  +|   3264: 30 30 01 04 05 03 01 04 05 03 01 04 05 03 1f 02   00..............
         3221  +|   3280: 03 01 02 03 01 02 03 01 08 35 30 30 30 30 30 30   .........5000000
         3222  +|   3296: 30 1c 02 04 01 02 04 01 02 04 01 01 36 01 02 04   0...........6...
         3223  +|   3312: 01 02 04 01 02 04 01 06 62 69 6e 61 72 79 03 06   ........binary..
         3224  +|   3328: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         3225  +|   3344: 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02   ................
         3226  +|   3360: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         3227  +|   3376: 03 06 01 02 02 03 06 01 02 02 01 05 63 6c 61 6e   ............clan
         3228  +|   3392: 67 01 02 03 01 02 03 01 02 03 02 07 6f 6d 70 69   g...........ompi
         3229  +|   3408: 6c 65 72 01 02 02 01 02 02 01 02 02 01 06 64 62   ler...........db
         3230  +|   3424: 73 74 61 74 07 02 03 01 02 03 01 02 03 02 04 65   stat...........e
         3231  +|   3440: 62 75 67 04 02 02 01 02 02 01 02 02 01 06 65 6e   bug...........en
         3232  +|   3456: 61 62 6c 65 07 02 02 01 02 02 01 02 02 01 02 02   able............
         3233  +|   3472: 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01   ................
         3234  +|   3488: 02 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02   ................
         3235  +|   3504: 02 01 02 02 01 02 02 01 02 02 01 02 02 01 02 02   ................
         3236  +|   3520: 01 02 02 02 08 78 74 65 6e 73 69 6f 6e 1f 02 04   .....xtension...
         3237  +|   3536: 01 02 04 01 02 04 01 04 66 74 73 34 0a 02 03 03   ........fts4....
         3238  +|   3552: 01 02 01 02 03 04 01 35 0d 02 03 01 02 03 01 02   .......5........
         3239  +|   3568: 03 01 07 67 65 6f 70 6f 6c 79 10 02 03 01 02 03   ...geopoly......
         3240  +|   3584: 01 02 03 01 05 6a 73 6f 6e 31 13 02 03 01 02 03   .....json1......
         3241  +|   3600: 01 02 03 01 04 6c 6f 61 64 1f 02 03 01 02 03 01   .....load.......
         3242  +|   3616: 02 03 01 03 6d 61 78 1c 02 02 01 02 02 01 02 02   ....max.........
         3243  +|   3632: 02 05 65 6d 6f 72 79 1c 02 03 01 02 03 01 02 03   ..emory.........
         3244  +|   3648: 04 04 73 79 73 35 16 02 03 01 02 03 01 02 03 01   ..sys5..........
         3245  +|   3664: 06 6e 6f 63 61 73 65 02 06 01 02 02 03 06 01 02   .nocase.........
         3246  +|   3680: 02 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02   ................
         3247  +|   3696: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3248  +|   3712: 06 01 02 02 03 06 01 02 02 03 06 01 12 02 03 06   ................
         3249  +|   3728: 01 02 02 01 04 6f 6d 69 74 1f 02 02 01 02 02 01   .....omit.......
         3250  +|   3744: 02 02 01 05 72 74 72 65 65 19 02 03 01 02 03 01   ....rtree.......
         3251  +|   3760: 02 03 04 02 69 6d 01 06 01 02 02 03 06 01 02 02   ....im..........
         3252  +|   3776: 03 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03   ................
         3253  +|   3792: 06 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06   ................
         3254  +|   3808: 01 02 02 03 06 01 02 02 03 06 01 02 02 03 06 01   ................
         3255  +|   3824: 02 02 01 0a 74 68 72 65 61 64 73 61 66 65 22 02   ....threadsafe..
         3256  +|   3840: 02 01 02 02 01 02 02 01 04 76 74 61 62 07 02 04   .........vtab...
         3257  +|   3856: 01 02 04 01 02 04 01 01 78 01 06 01 01 02 01 06   ........x.......
         3258  +|   3872: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3259  +|   3888: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3260  +|   3904: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3261  +|   3920: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3262  +|   3936: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3263  +|   3952: 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01   ................
         3264  +|   3968: 01 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01   ................
         3265  +|   3984: 02 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02   ................
         3266  +|   4000: 01 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01   ................
         3267  +|   4016: 06 01 01 02 01 06 01 01 02 01 06 01 01 02 01 06   ................
         3268  +|   4032: 01 01 02 01 06 01 01 02 01 06 01 01 02 04 18 13   ................
         3269  +|   4048: 0c 44 10 12 11 0f 47 13 0f 0c 12 10 0f 0e 10 0f   .D....G.........
         3270  +|   4064: 44 0f 10 40 15 0f 07 01 03 00 14 24 57 24 24 0f   D..@.......$W$$.
         3271  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3272  +| page 4 offset 12288
         3273  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         3274  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3275  +| page 5 offset 16384
         3276  +|      0: 0d 00 00 00 24 0c 1f 00 0f df 0f bd 0f 9b 0f 89   ....$...........
         3277  +|     16: 0f 76 0f 63 0f 44 0f 24 0f 04 0e ec 0e d3 0e ba   .v.c.D.$........
         3278  +|     32: 0e a2 0e 89 0e 70 e5 50 e3 90 e1 d0 e0 40 de a0   .....p.P.....@..
         3279  +|     48: dd 00 db 50 d9 90 d7 ea ca ea be d0 d6 40 d4 a0   ...P.........@..
         3280  +|     64: d3 00 d1 00 ce f0 cc e0 ca e0 c8 d0 c6 c0 c5 30   ...............0
         3281  +|     80: c3 90 c1 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
         3282  +|   3088: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18   ................
         3283  +|   3104: 24 05 00 25 0f 19 54 48 52 45 41 44 53 41 46 45   $..%..THREADSAFE
         3284  +|   3120: 3d 30 58 42 49 4e 41 52 59 18 23 05 00 25 0f 19   =0XBINARY.#..%..
         3285  +|   3136: 54 48 52 45 41 44 53 41 46 45 3d 30 58 4e 4f 43   THREADSAFE=0XNOC
         3286  +|   3152: 41 53 45 17 22 05 00 25 0f 17 54 48 52 45 41 44   ASE....%..THREAD
         3287  +|   3168: 53 41 46 45 3d 30 05 00 33 0f 19 4f 4d 49 54 20   SAFE=0..3..OMIT 
         3288  +|   3184: 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 58 42   LOAD EXTENSIONXB
         3289  +|   3200: 49 4e 41 52 59 1f 20 05 00 33 0f 19 4f 4d 49 54   INARY. ..3..OMIT
         3290  +|   3216: 20 4c 4f 41 44 20 45 58 54 45 4e 53 49 4f 4e 58    LOAD EXTENSIONX
         3291  +|   3232: 4e 4f 43 41 53 45 1e 1f 05 00 33 0f 17 4f 4d 49   NOCASE....3..OMI
         3292  +|   3248: 54 20 4c f4 14 42 04 55 85 44 54 e5 34 94 f4 e5   T L..B.U.DT.4...
         3293  +|   3264: 85 25 45 24 94 d1 f1 e0 50 03 30 f1 94 d4 15 82   .%E$....P.0.....
         3294  +|   3280: 04 d4 54 d4 f5 25 93 d3 53 03 03 03 03 03 03 05   ..T..%..S.......
         3295  +|   3296: 84 24 94 e4 15 25 91 f1 d0 50 03 30 f1 94 d4 15   .$...%...P.0....
         3296  +|   3312: 82 04 d4 54 d4 f5 25 93 d3 53 03 03 03 03 03 03   ...T..%..S......
         3297  +|   3328: 05 84 e4 f4 34 15 34 51 e1 c0 50 03 30 f1 74 d4   ....4.4Q..P.0.t.
         3298  +|   3344: 15 82 04 d4 54 d4 f2 90 f1 74 54 e4 14 24 c4 52   ....T....tT..$.R
         3299  +|   3360: 04 74 54 f5 04 f4 c5 95 85 25 45 24 94 d1 70 f0   .tT......%E$..p.
         3300  +|   3376: 50 02 30 f1 94 54 e4 14 24 c4 52 04 65 45 33 55   P.0..T..$.R.eE3U
         3301  +|   3392: 84 24 94 e4 15 25 91 70 e0 50 02 30 f1 94 54 e4   .$...%.p.P.0..T.
         3302  +|   3408: 14 24 c4 52 04 65 45 33 55 84 e4 f4 34 15 34 51   .$.R.eE3U...4.4Q
         3303  +|   3424: 60 d0 50 02 30 f1 74 54 e4 14 24 c4 52 04 65 45   `.P.0.tT..$.R.eE
         3304  +|   3440: 33 55 85 25 45 24 94 d1 70 c0 50 02 30 f1 94 54   3U.%E$..p.P.0..T
         3305  +|   3456: e4 14 24 c4 52 04 65 45 33 45 84 24 94 e4 15 25   ..$.R.eE3E.$...%
         3306  +|   3472: 91 70 b0 50 02 30 f1 94 54 e4 14 24 c4 52 04 65   .p.P.0..T..$.R.e
         3307  +|   3488: 45 33 45 84 e4 f4 34 15 34 51 60 a0 74 54 e4 14   E3E...4.4Q`.tT..
         3308  +|   3504: 24 c4 52 04 65 45 33 45 85 25 45 24 94 d1 e0 90   $.R.eE3E.%E$....
         3309  +|   3520: 50 03 10 f1 94 54 e4 14 24 c4 52 04 44 25 35 44   P....T..$.R.D%5D
         3310  +|   3536: 15 42 05 65 44 14 25 84 24 94 e4 15 25 91 e0 80   .B.eD.%.$...%...
         3311  +|   3552: 50 03 10 f1 94 54 e4 14 24 c4 52 04 44 25 35 44   P....T..$.R.D%5D
         3312  +|   3568: 15 42 05 65 44 14 25 84 e4 f4 34 15 34 51 d0 70   .B.eD.%...4.4Q.p
         3313  +|   3584: 50 03 10 f1 74 54 e4 14 24 c4 52 04 44 25 35 44   P...tT..$.R.D%5D
         3314  +|   3600: 15 42 05 65 44 14 25 85 25 45 24 94 d1 10 60 50   .B.eD.%.%E$...`P
         3315  +|   3616: 01 70 f1 94 44 54 25 54 75 84 24 94 e4 15 25 91   .p..DT%Tu.$...%.
         3316  +|   3632: 10 50 50 01 70 f1 94 44 54 25 54 75 84 e4 f4 34   .PP.p..DT%Tu...4
         3317  +|   3648: 15 34 51 00 40 50 01 70 f1 74 44 54 25 54 75 85   .4Q.@P.p.tDT%Tu.
         3318  +|   3664: 25 45 24 94 d2 00 30 50 03 50 f1 94 34 f4 d5 04   %E$...0P.P..4...
         3319  +|   3680: 94 c4 55 23 d6 36 c6 16 e6 72 d3 62 e3 02 e3 05   ..U#.6...r.b....
         3320  +|   3696: 84 24 94 e4 15 25 92 00 20 50 03 50 f1 94 34 f4   .$...%.. P.P..4.
         3321  +|   3712: d5 04 94 c4 55 23 d6 36 c6 16 e6 72 d3 62 e3 02   ....U#.6...r.b..
         3322  +|   3728: e3 05 84 e4 f4 34 15 34 51 f0 10 50 03 50 f1 74   .....4.4Q..P.P.t
         3323  +|   3744: 34 f4 d5 04 94 c4 55 23 d6 36 c6 16 e6 72 d3 62   4.....U#.6...r.b
         3324  +|   3760: e3 02 e3 05 85 25 45 24 94 d0 d0 00 00 02 40 ee   .....%E$......@.
         3325  +|   3776: 00 00 ff 80 ff 00 fe 80 fe 00 fd 80 fd 00 fc 80   ................
         3326  +|   3792: fc 00 fb 80 fb 00 fa 80 fa 00 f9 80 f9 00 f8 80   ................
         3327  +|   3808: f8 00 f7 80 f7 00 f6 80 f6 00 f5 80 f5 00 f4 80   ................
         3328  +|   3824: f4 00 f3 80 f3 00 f2 80 f2 00 f1 80 f1 00 f0 80   ................
         3329  +|   3840: f0 00 ef 80 ef 00 ee 80 ee 00 00 00 00 00 00 00   ................
         3330  +| page 6 offset 20480
         3331  +|   3808: 06 24 03 00 12 02 01 01 06 23 03 00 12 02 01 01   .$.......#......
         3332  +|   3824: 06 22 03 00 12 02 01 01 06 21 03 00 12 03 01 01   .........!......
         3333  +|   3840: 06 20 03 00 12 03 01 01 06 1f 03 00 12 03 01 01   . ..............
         3334  +|   3856: 06 1e 03 00 12 03 01 01 06 1d 03 00 12 03 01 01   ................
         3335  +|   3872: 06 1c 03 00 12 03 01 01 06 1b 03 00 12 02 01 01   ................
         3336  +|   3888: 06 1a 03 00 12 02 01 01 06 19 03 00 12 02 01 01   ................
         3337  +|   3904: 06 18 03 00 12 02 01 01 06 17 03 00 12 02 01 01   ................
         3338  +|   3920: 06 16 03 00 12 02 01 01 06 15 03 00 12 02 01 01   ................
         3339  +|   3936: 06 14 03 00 12 02 01 01 06 13 03 00 12 02 01 01   ................
         3340  +|   3952: 06 12 03 00 12 02 01 01 06 11 03 00 12 02 01 01   ................
         3341  +|   3968: 06 10 03 00 12 02 01 01 06 0f 03 00 12 02 01 01   ................
         3342  +|   3984: 06 0e 03 00 12 02 01 01 06 0d 03 00 12 02 01 01   ................
         3343  +|   4000: 06 0c 03 00 12 02 01 01 06 0b 03 00 12 02 01 01   ................
         3344  +|   4016: 06 0a 03 00 12 02 01 01 06 09 03 00 12 03 01 01   ................
         3345  +|   4032: 06 08 03 00 12 03 01 01 06 07 03 00 12 03 01 01   ................
         3346  +|   4048: 06 06 03 00 12 01 01 01 06 05 03 00 12 01 01 01   ................
         3347  +|   4064: 06 04 03 00 12 01 01 01 06 03 03 00 12 05 01 01   ................
         3348  +|   4080: 06 02 03 00 12 05 01 01 06 01 03 00 12 05 01 01   ................
         3349  +| page 7 offset 24576
         3350  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3351  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3352  +| end crash-e114c036e13dde.db
         3353  +}]} {}
         3354  +
         3355  +do_catchsql_test 29.1 {
         3356  +  CREATE VIRTUAL TABLE t3 USING fts5vocab('t1','col');
         3357  +} {0 {}}
         3358  +do_catchsql_test 29.2 {
         3359  +  SELECT rowid, quote(term), * FROM t3 WHERE term=='nocase';
         3360  +} {1 {database disk image is malformed}}
         3361  +
         3362  +#-------------------------------------------------------------------------
         3363  +reset_db
         3364  +do_test 30.0 {
         3365  +  sqlite3 db {}
         3366  +  db deserialize [decode_hexdb {
         3367  +| size 40960 pagesize 4096 filename crash-eef41e30b388a0.db
         3368  +| page 1 offset 0
         3369  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         3370  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 0a   .....@  ........
         3371  +|     32: 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 04   ................
         3372  +|     48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00   ................
         3373  +|     96: 00 00 00 00 0d 00 00 00 0d 0b 6e 00 0f a3 0f 4c   ..........n....L
         3374  +|    112: 0e e1 0e 81 0e 24 0d cc 0d 72 0d 1b 0c b0 0c 50   .....$...r.....P
         3375  +|    128: 0b f8 0b b3 0b 6e 00 00 00 00 00 00 00 00 00 00   .....n..........
         3376  +|   2912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 0d   ..............C.
         3377  +|   2928: 06 17 11 11 08 75 74 61 62 6c 65 74 34 74 34 43   .....utablet4t4C
         3378  +|   2944: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41   REATE VIRTUAL TA
         3379  +|   2960: 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74 73   BLE t4 USING fts
         3380  +|   2976: 35 76 6f 63 61 62 28 27 74 32 27 2c 20 27 72 6f   5vocab('t2', 'ro
         3381  +|   2992: 77 27 29 43 0c 06 17 11 11 08 75 74 61 62 6c 65   w')C......utable
         3382  +|   3008: 74 33 74 33 43 52 45 41 54 45 20 56 49 52 54 55   t3t3CREATE VIRTU
         3383  +|   3024: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e   AL TABLE t3 USIN
         3384  +|   3040: 47 20 66 74 73 35 76 6f 63 61 62 28 27 74 31 27   G fts5vocab('t1'
         3385  +|   3056: 2c 20 27 72 6f 77 27 29 56 0b 06 17 1f 1f 01 7d   , 'row')V.......
         3386  +|   3072: 74 61 62 6c 65 74 32 5f 63 6f 6e 66 69 67 74 32   tablet2_configt2
         3387  +|   3088: 5f 63 6f 6e 66 69 67 0a 43 52 45 41 54 45 20 54   _config.CREATE T
         3388  +|   3104: 41 42 4c 45 20 27 74 32 5f 63 6f 6e 66 69 67 27   ABLE 't2_config'
         3389  +|   3120: 28 6b 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20   (k PRIMARY KEY, 
         3390  +|   3136: 76 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44   v) WITHOUT ROWID
         3391  +|   3152: 5e 0a 07 17 21 21 01 81 07 74 61 62 6c 65 74 32   ^...!!...tablet2
         3392  +|   3168: 5f 63 6f 6e 74 65 6e 74 74 32 5f 63 6f 6e 74 65   _contentt2_conte
         3393  +|   3184: 6e 74 09 43 52 45 41 54 45 20 54 41 42 4c 45 20   nt.CREATE TABLE 
         3394  +|   3200: 27 74 32 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20   't2_content'(id 
         3395  +|   3216: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20   INTEGER PRIMARY 
         3396  +|   3232: 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32 29   KEY, c0, c1, c2)
         3397  +|   3248: 69 09 07 17 19 19 01 81 2d 74 61 62 6c 65 74 32   i.......-tablet2
         3398  +|   3264: 5f 69 64 78 74 32 5f 69 64 78 08 43 52 45 41 54   _idxt2_idx.CREAT
         3399  +|   3280: 45 20 54 41 42 4c 45 20 27 74 32 5f 69 64 78 27   E TABLE 't2_idx'
         3400  +|   3296: 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70 67   (segid, term, pg
         3401  +|   3312: 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28   no, PRIMARY KEY(
         3402  +|   3328: 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49   segid, term)) WI
         3403  +|   3344: 54 48 4f 55 54 20 52 4f 57 49 44 55 08 07 17 1b   THOUT ROWIDU....
         3404  +|   3360: 1b 01 81 01 74 61 62 6c 65 74 32 5f 64 61 74 61   ....tablet2_data
         3405  +|   3376: 74 32 5f 64 61 74 61 07 43 52 45 41 54 45 20 54   t2_data.CREATE T
         3406  +|   3392: 41 42 4c 45 20 27 74 32 5f 64 61 74 61 27 28 69   ABLE 't2_data'(i
         3407  +|   3408: 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52   d INTEGER PRIMAR
         3408  +|   3424: 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c 4f   Y KEY, block BLO
         3409  +|   3440: 42 29 58 07 07 17 11 11 08 81 1d 74 61 62 6c 65   B)X........table
         3410  +|   3456: 74 32 74 32 43 52 45 41 54 45 20 56 49 52 54 55   t2t2CREATE VIRTU
         3411  +|   3472: 41 4c 20 54 41 42 4c 45 20 74 32 20 55 53 49 4e   AL TABLE t2 USIN
         3412  +|   3488: 47 20 66 74 73 35 28 27 61 27 2c 5b 62 5d 2c 22   G fts5('a',[b],.
         3413  +|   3504: 63 22 2c 64 65 74 61 69 6c 3d 6e 6f 6e 65 2c 63   c.,detail=none,c
         3414  +|   3520: 6f 6c 75 6d 6e 73 69 7a 65 3d 30 29 56 06 06 17   olumnsize=0)V...
         3415  +|   3536: 1f 1f 01 7d 74 61 62 6c 65 74 31 5f 63 6f 6e 66   ....tablet1_conf
         3416  +|   3552: 69 67 74 31 5f 63 6f 6e 66 69 67 06 43 52 45 41   igt1_config.CREA
         3417  +|   3568: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f 6e   TE TABLE 't1_con
         3418  +|   3584: 66 69 67 27 28 6b 20 50 52 49 4d 41 52 59 20 4b   fig'(k PRIMARY K
         3419  +|   3600: 45 59 2c 20 76 29 20 57 49 54 48 4f 55 54 20 52   EY, v) WITHOUT R
         3420  +|   3616: 4f 57 49 44 5b 05 07 17 21 21 01 81 01 74 61 62   OWID[...!!...tab
         3421  +|   3632: 6c 65 74 31 5f 64 6f 63 73 69 7a 65 74 31 5f 64   let1_docsizet1_d
         3422  +|   3648: 6f 63 73 69 7a 65 05 43 52 45 41 54 45 20 54 41   ocsize.CREATE TA
         3423  +|   3664: 42 4c 45 20 27 74 31 5f 64 6f 63 73 69 7a 65 27   BLE 't1_docsize'
         3424  +|   3680: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         3425  +|   3696: 41 52 59 20 4b 45 59 2c 20 73 7a 20 42 4c 4f 42   ARY KEY, sz BLOB
         3426  +|   3712: 29 5e 04 07 17 21 21 01 81 07 74 61 62 6c 65 74   )^...!!...tablet
         3427  +|   3728: 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f 6e 74   1_contentt1_cont
         3428  +|   3744: 65 6e 74 04 43 52 45 41 54 45 20 54 41 42 4c 45   ent.CREATE TABLE
         3429  +|   3760: 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 69 64    't1_content'(id
         3430  +|   3776: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59    INTEGER PRIMARY
         3431  +|   3792: 20 4b 45 59 2c 20 63 30 2c 20 63 31 2c 20 63 32    KEY, c0, c1, c2
         3432  +|   3808: 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65 74   )i.......-tablet
         3433  +|   3824: 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45 41   1_idxt1_idx.CREA
         3434  +|   3840: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64 78   TE TABLE 't1_idx
         3435  +|   3856: 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20 70   '(segid, term, p
         3436  +|   3872: 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59   gno, PRIMARY KEY
         3437  +|   3888: 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57   (segid, term)) W
         3438  +|   3904: 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07 17   ITHOUT ROWIDU...
         3439  +|   3920: 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61 74   .....tablet1_dat
         3440  +|   3936: 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45 20   at1_data.CREATE 
         3441  +|   3952: 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27 28   TABLE 't1_data'(
         3442  +|   3968: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41   id INTEGER PRIMA
         3443  +|   3984: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c   RY KEY, block BL
         3444  +|   4000: 4f 42 29 5b 01 07 17 11 11 08 81 23 74 61 62 6c   OB)[.......#tabl
         3445  +|   4016: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         3446  +|   4032: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         3447  +|   4048: 4e 47 20 66 74 73 35 28 61 2c 62 20 75 6e 69 6e   NG fts5(a,b unin
         3448  +|   4064: 64 65 78 65 64 2c 63 2c 74 6f 6b 65 6e 69 7a 65   dexed,c,tokenize
         3449  +|   4080: 3d 22 70 6f 72 74 65 72 20 61 73 63 69 69 22 29   =.porter ascii.)
         3450  +| page 2 offset 4096
         3451  +|      0: 0d 0f 68 00 05 0f 13 00 0f e6 0f 13 0f a8 0f 7c   ..h............|
         3452  +|     16: 0f 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00   .*..............
         3453  +|   3856: 00 00 00 15 0a 03 00 30 00 00 00 00 01 03 03 00   .......0........
         3454  +|   3872: 03 01 01 01 02 01 01 03 01 01 37 8c 80 80 80 80   ..........7.....
         3455  +|   3888: 01 03 00 74 00 00 00 2e 02 30 61 03 02 02 01 01   ...t.....0a.....
         3456  +|   3904: 62 03 02 03 01 01 63 03 02 04 01 01 67 03 06 01   b.....c.....g...
         3457  +|   3920: 02 02 01 01 68 03 06 01 02 03 01 01 69 03 06 01   ....h.......i...
         3458  +|   3936: 02 04 00 00 66 46 08 08 0f ef 00 14 2a 00 00 00   ....fF......*...
         3459  +|   3952: 00 01 02 02 00 02 01 01 01 02 01 01 25 88 80 80   ............%...
         3460  +|   3968: 80 80 01 03 00 50 00 00 00 1f 02 30 67 02 08 02   .....P.....0g...
         3461  +|   3984: 01 02 02 01 01 68 02 08 03 01 02 03 01 01 69 02   .....h........i.
         3462  +|   4000: 08 04 01 02 04 04 09 09 37 84 80 80 80 80 01 03   ........7.......
         3463  +|   4016: 00 74 00 00 00 2e 02 30 61 01 02 02 01 01 62 01   .t.....0a.....b.
         3464  +|   4032: 02 03 01 01 63 01 02 04 01 01 67 01 06 01 02 02   ....c.....g.....
         3465  +|   4048: 01 01 68 01 06 01 02 03 01 01 69 01 06 01 02 04   ..h.......i.....
         3466  +|   4064: 04 06 06 06 08 08 07 01 03 00 14 03 09 00 09 00   ................
         3467  +|   4080: 00 00 11 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3468  +| page 3 offset 8192
         3469  +|      0: 0a 00 00 00 03 0f ec 00 0f fa 0f f3 0f ec 00 00   ................
         3470  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 06 04 01 0c   ................
         3471  +|   4080: 01 03 02 06 04 01 0c 01 02 02 05 04 09 0c 01 02   ................
         3472  +| page 4 offset 12288
         3473  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3474  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3475  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3476  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3477  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3478  +|   4080: 17 61 20 62 20 63 64 20 52 06 66 72 06 82 06 90   .a b cd R.fr....
         3479  +| page 5 offset 16384
         3480  +|      0: d0 00 00 00 30 fe 80 00 ff 80 ff 00 fe 00 00 00   ....0...........
         3481  +|   4064: 00 00 00 00 00 00 00 00 06 03 03 00 12 03 00 03   ................
         3482  +|   4080: 06 02 03 00 12 03 00 03 06 01 03 00 12 03 00 03   ................
         3483  +| page 6 offset 20480
         3484  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3485  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3486  +| page 7 offset 24576
         3487  +|      0: 0d 00 00 00 03 0f 9e 00 0f e6 0f ef 0f 9e 00 00   ................
         3488  +|   3984: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 84   ..............A.
         3489  +|   4000: 80 80 80 80 01 04 00 81 06 00 00 00 34 02 30 61   ............4.0a
         3490  +|   4016: 01 01 01 01 01 62 01 01 01 01 01 63 01 01 01 01   .....b.....c....
         3491  +|   4032: 01 64 01 01 01 65 01 01 01 66 01 01 01 67 01 01   .d...e...f...g..
         3492  +|   4048: 01 01 01 68 01 01 01 01 01 69 01 01 01 04 06 06   ...h.....i......
         3493  +|   4064: 06 04 04 04 06 06 07 01 03 00 14 03 09 09 09 0f   ................
         3494  +|   4080: 0a 03 00 24 00 00 00 00 01 01 01 00 01 01 01 01   ...$............
         3495  +| page 8 offset 28672
         3496  +|      0: 0a 00 00 00 01 0f fa 00 0f fa 00 00 00 00 00 00   ................
         3497  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         3498  +| page 9 offset 32768
         3499  +|      0: 0d 00 00 00 03 0f be 00 0f ea 0f d4 0f be 00 00   ................
         3500  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 03   ................
         3501  +|   4032: 05 00 17 17 17 61 20 62 20 63 67 20 68 20 69 67   .....a b cg h ig
         3502  +|   4048: 20 68 20 69 14 02 05 00 17 17 17 67 20 68 20 69    h i.......g h i
         3503  +|   4064: 61 20 62 20 63 67 20 68 20 69 14 01 05 00 17 17   a b cg h i......
         3504  +|   4080: 17 61 20 62 20 63 64 20 65 20 66 67 20 68 20 69   .a b cd e fg h i
         3505  +| page 10 offset 36864
         3506  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         3507  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         3508  +| end crash-eef41e30b388a0.db
         3509  +}]} {}
         3510  +
         3511  +do_catchsql_test 30.1 {
         3512  +  SELECT fts5_decode(id, block) FROM t1_data;
         3513  +} {1 {database disk image is malformed}}
  3169   3514   
  3170   3515   sqlite3_fts5_may_be_corrupt 0
  3171   3516   finish_test
  3172   3517