1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Ensure that all content that is copied into the -shm file during recovery

has been initialized, even in the case of no valid WAL frames.
Private email from Mirchev.

FossilOrigin-Name: 64c93bc7e643433ddd79b9dc67e50d3d9fe2228a1234e27e143b06150d556abd
This commit is contained in:
drh
2026-10-23 09:08:13 +00:00
parent 20822819ad
commit 02225da9a9
4 changed files with 43 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
C Fix\stwo\sminor\sissues\swith\sthe\sgeopoly\sextension.\nBugs\s[bugs:/info/2026-10-21T02:53:43Z]\nand\s[bugs:/info/2026-10-21T05:30:42Z].
D 2026-10-23T00:49:30.472
C Ensure\sthat\sall\scontent\sthat\sis\scopied\sinto\sthe\s-shm\sfile\sduring\srecovery\nhas\sbeen\sinitialized,\seven\sin\sthe\scase\sof\sno\svalid\sWAL\sframes.\nPrivate\semail\sfrom\sMirchev.
D 2026-10-23T09:08:13.095
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -886,7 +886,7 @@ F src/vdbetrace.c 49e689f751505839742f4a243a1a566e57d5c9eaf0d33bbaa26e2de3febf7b
F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3
F src/vtab.c b1a9d78fe5bf25e47daf9a8f88eb6875e8061f24ff343187dbe94e95e0229260
F src/vxworks.h 9d18819c5235b49c2340a8a4d48195ec5d5afb637b152406de95a9436beeaeab
F src/wal.c 41438914e455bbc42ccff8545eab4c711f91233e480337e44a3d5fdf121fce74
F src/wal.c dcbec16ea54dbf902282b600798a59700eb10aa916790039bc0fdfdc7583d67b
F src/wal.h c6251cfc1950643a976625ca452e46dc9b466b4f5dd2e85f244f29f79bf68ace
F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014
F src/where.c 801d94357804abe447b87c64d33ef186c6dc79b38beb3d128cac3e5a1f3c3f44
@@ -2094,7 +2094,7 @@ F test/walbak.test 018d4e5a3d45c6298d11b99f09a8ef6876527946
F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
F test/walblock.test 6bb472e82730e7e4e81395e907a01d8cfc2bd9e1f01f8a9184ca572e2955a4bf
F test/walckptnoop.test 5f6123750f40cb86633a7e014f9fb805d0eb494b811840086dc72e554e68c7c1
F test/walcksum.test 50e204500eed9c691b6045e467bb2923f49aa93d8adf315e2be135fdb202c1c2
F test/walcksum.test 3bcd4266cb1cdfd0b8a4e08c2e9b8953d227ae0268094faffb7148d8bdcafe99
F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a
F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36
F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af
@@ -2297,8 +2297,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P 52d0c0b3d18b032e2d2c006a5d60df4c65da3b95200eaaffddb0ede9ed63f29f
R d78d70775b4d143ef12b7c5ee188934a
P d6f1df8c0bbc2c04d9cdbbf33ff6ff9ba35d80f6e33ddab688827e7e2fe568d5
R 640900977979336eef10d68b9ad49258
U drh
Z 7b38a1ec45246b3ad601d2365201294e
Z b3d7794e332714fd8c46ef06da2d881e
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
d6f1df8c0bbc2c04d9cdbbf33ff6ff9ba35d80f6e33ddab688827e7e2fe568d5
64c93bc7e643433ddd79b9dc67e50d3d9fe2228a1234e27e143b06150d556abd

View File

@@ -1514,6 +1514,7 @@ static int walIndexRecover(Wal *pWal){
rc = SQLITE_NOMEM_BKPT;
goto recovery_error;
}
memset(aFrame, 0, szFrame + WALINDEX_PGSZ);
aData = &aFrame[WAL_FRAME_HDRSIZE];
aPrivate = (u32*)&aData[szPage];

View File

@@ -479,5 +479,39 @@ do_execsql_test 5.3 {
SELECT i, t FROM t1
} {1 one 2 two 3 three 8 eight 9 nine}
#-------------------------------------------------------------------------
# If the WAL file has a valid header but not even one complete frame,
# recovery must not copy uninitialized memory into the wal-index.
#
catch { db close }
catch { db2 close }
forcedelete test.db test.db-wal test.db-shm
sqlite3 db test.db
do_execsql_test 6.1 {
PRAGMA journal_mode = WAL;
PRAGMA wal_autocheckpoint = 0;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('abc');
} {wal 0}
do_test 6.2 {
set walhdr [hexio_read test.db-wal 0 32]
db close
forcedelete test.db-wal test.db-shm
close [open test.db-wal w]
hexio_write test.db-wal 0 "$walhdr[string repeat 00 100]"
file size test.db-wal
} {132}
do_test 6.3 {
# Leave non-zero data in recently freed heap memory.
set L [list]
for {set i 0} {$i<20} {incr i} { lappend L [string repeat "abcdef" 7000] }
unset L
sqlite3 db test.db
execsql { SELECT * FROM t1 }
} {abc}
do_test 6.4 {
regexp {^0*$} [hexio_read test.db-shm 136 [expr 32768-136]]
} {1}
db close
finish_test