1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix an assert() that can be false when doing an incremental vacuum on a

corrupt database file.  dbsqlfuzz cced0668cfd4da4eb2382cb9dd26c17c64aaff76.

FossilOrigin-Name: 15b801016fa204b8e4b7c89e236adb73dd57687959d825664de5097370b24030
This commit is contained in:
drh
2021-04-05 17:50:38 +00:00
parent 240e36c0e3
commit e3814ee026
4 changed files with 68 additions and 11 deletions

View File

@@ -832,5 +832,61 @@ ifcapable mmap {
set res
} {1 2 3 4}
}
# 2021-04-05 dbsqlfuzz cced0668cfd4da4eb2382cb9dd26c17c64aaff76
#
# This is an incremental vacuum database that has one free page that
# needs to be filled. After removing the last page from the end of
# the database file to fill the free page slot, the last page that
# is left is the tail of an overflow chain.
#
# But the size of the database file is shorter than the actual data
# so that after incremental vacuum runs, the file is actually too
# small to hold the last page of the overflow chain.
#
# At one point this caused an assertion fault in
# sqlite3PagerTruncateImage().
#
do_test incrvacuum-17.0 {
sqlite3 db {}
database_may_be_corrupt
db deserialize [decode_hexdb {
| size 20480 pagesize 4096 filename x2.db
| page 1 offset 0
| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
| 16: 10 00 01 01 00 40 20 20 00 00 00 05 00 00 00 07 .....@ ........
| 32: 00 00 00 04 00 00 00 01 00 00 00 03 00 00 00 04 ................
| 48: 00 00 00 00 00 00 00 03 00 00 00 01 00 00 00 00 ................
| 64: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
| 96: 00 2e 53 60 0d 0f dc 00 01 0f b8 00 0f b8 0f b8 ..S`............
| 4016: 00 00 00 00 00 00 00 00 22 02 06 17 11 11 01 31 ...............1
| 4032: 74 61 62 6c 65 74 32 74 32 03 43 52 45 41 54 45 tablet2t2.CREATE
| 4048: 20 54 41 42 4c 45 20 74 32 28 79 29 00 00 00 24 TABLE t2(y)...$
| 4064: 11 11 01 31 74 61 62 6c 65 74 31 74 31 03 43 52 ...1tablet1t1.CR
| 4080: 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 78 29 EATE TABLE t1(x)
| page 2 offset 4096
| 0: 01 00 00 00 00 02 00 00 00 00 03 00 00 00 03 04 ................
| 16: 00 00 00 05 03 00 00 00 03 00 00 00 00 00 00 00 ................
| page 3 offset 8192
| 0: 0d 00 00 00 02 05 47 00 08 dd 05 47 00 00 00 00 ......G....G....
| 1344: 00 00 00 00 00 00 00 a7 0b 02 03 ce 1c 00 00 00 ................
| 2256: 00 00 00 00 00 00 00 00 00 00 00 00 07 ce 14 01 ................
| 2272: 04 81 9c 2c 00 00 00 00 00 00 00 00 00 00 00 00 ...,............
| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
| page 4 offset 12288
| 0: 00 00 00 00 00 00 00 00 08 dd 05 47 00 00 00 00 ...........G....
| 1344: 00 00 00 00 00 00 00 a7 0b 02 03 ce 1c 00 00 00 ................
| 2256: 00 00 00 00 00 00 00 00 00 00 00 00 07 ce 14 01 ................
| 2272: 04 81 9c 2c 00 00 00 00 00 00 00 00 00 00 00 00 ...,............
| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ................
| page 5 offset 16384
| 0: 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 ................
| end x2.db
}]} {}
do_catchsql_test incrvacuum-17.1 {
PRAGMA writable_schema=ON;
PRAGMA incremental_vacuum(10);
} {0 {}}
finish_test