SQLite

Check-in [c73886ed74]
Login

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

Overview
Comment:Test that a corrupted WAL hash-table does not put the library into an infinite loop.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c73886ed7497c0daf798c3b02ca6f5a1c2addde3
User & Date: dan 2010-07-14 07:06:48.000
Context
2010-07-14
08:20
Add tests to pagerfault.test. (check-in: b092f2a74b user: dan tags: trunk)
07:06
Test that a corrupted WAL hash-table does not put the library into an infinite loop. (check-in: c73886ed74 user: dan tags: trunk)
06:20
Fix a typo in the IS_BIG_INT macro used by coverage test instrumentation. (check-in: 5314ca3928 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/wal2.test.
945
946
947
948
949
950
951
















































952
953
954
breakpoint
do_test wal2-10.2.3 { 
  lset hdr 0 3007001
  wal_fix_walindex_cksum hdr 
  set_tvfs_hdr $::filename $hdr
  catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}

















































finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
breakpoint
do_test wal2-10.2.3 { 
  lset hdr 0 3007001
  wal_fix_walindex_cksum hdr 
  set_tvfs_hdr $::filename $hdr
  catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
db close
tvfs delete

#-------------------------------------------------------------------------
# This block of tests - wal2-11.* - tests that it is not possible to put
# the library into an infinite loop by presenting it with a corrupt
# hash table (one that appears to contain a single chain of infinite 
# length).
#
#   wal2-11.1.*: While reading the hash-table.
#
#   wal2-11.2.*: While writing the hash-table.
#
testvfs tvfs -default 1
do_test wal2-11.0 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA journal_mode = WAL;
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1, 2, 3);
    INSERT INTO t1 VALUES(4, 5, 6);
    INSERT INTO t1 VALUES(7, 8, 9);
    SELECT * FROM t1;
  }
} {wal 1 2 3 4 5 6 7 8 9}

do_test wal2-11.1.1 {
  sqlite3 db2 test.db
  execsql { SELECT name FROM sqlite_master } db2
} {t1}

# Fill up the hash table on the first page of shared memory with 0x55 bytes.
#
set blob [string range [tvfs shm $::filename] 0 16383]
append blob [string repeat [binary format c 0x55] 16384]
tvfs shm $::filename $blob

do_test wal2-11.2 {
  catchsql { SELECT * FROM t1 } db2
} {1 {database disk image is malformed}}

do_test wal2-12.1 {
  catchsql { INSERT INTO t1 VALUES(10, 11, 12) }
} {1 {database disk image is malformed}}

db close
db2 close
tvfs delete

finish_test