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

Fix a problem causing the write-lock to be held when it should not be in some circumstances following a SEH exception.

FossilOrigin-Name: 7eb5accb7cf937fc967dcd86da0af813fb18a2697348bd231fbefd3c09b930ab
This commit is contained in:
dan
2025-01-30 17:04:28 +00:00
parent 462888819e
commit df54ecb1bf
4 changed files with 26 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
C Have\ssqlite3_enable_setlk(-1)\sconfigure\sindefinite\sblocking\slocks\swhere\sthey\sare\ssupported.
D 2025-01-30T15:26:16.127
C Fix\sa\sproblem\scausing\sthe\swrite-lock\sto\sbe\sheld\swhen\sit\sshould\snot\sbe\sin\ssome\scircumstances\sfollowing\sa\sSEH\sexception.
D 2025-01-30T17:04:28.336
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -858,7 +858,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8
F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3
F src/vtab.c 316cd48e9320660db3047cd306cd056e4361180cebb4d0f10a39244e10c11422
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 20550245b9a82f94736e905ee7df8f549e1301ba40e9f2cb51139e36d49c3c0f
F src/wal.c 6da5a05c124bad1e530cf83bafa07d28afdda20c28b276de49948ef8295d9e84
F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452
F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014
F src/where.c 9ad3dea8003a8913da6a4ca8322e2fe30773f46e88a0d4fbf9db13bdb999efa2
@@ -2022,7 +2022,7 @@ F test/walro2.test 33955a6fd874dd9724005e17f77fef89d334b3171454a1256fe4941a96766
F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68
F test/walseh1.test bae700eb99519b6d5cd3f893c04759accc5a59c391d4189fe4dd6995a533442b
F test/walsetlk.test 9c5b92f9a20252540fedf9ffa6ee3d1b8af08ea4b80d0144d9b88e6c0c1de80d
F test/walsetlk2.test def90f1c8cf47c5128bd3d12171ff1ed6c79f78dcb50c8c2cacf030fc78566a0
F test/walsetlk2.test 5ae8662a28c013e8df2ce975f9e3577a7f239aeb4622bb8d4d0ca8e16c0c132e
F test/walshared.test 42e3808582504878af237ea02c42ca793e8a0efaa19df7df26ac573370dbc7a3
F test/walslow.test 0c51843836c9dcf40a5ac05aa781bfb977b396ee2c872d92bd48b79d5dd9aa23
F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747
@@ -2203,8 +2203,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 4a7eb492797abb47b18b7dfc557aeae43a0dea5b861efc203398d5059b10d131
R 742ff1ca774eae27b30e6d13698e33be
P 62009565d2f2a2c4d347e1da0d5b4ad43056742df47fd6ddb92e62f53a2b57f1
R 1ce6d89df3820633838b6629306f6da1
U dan
Z 0c159766f95122a144fb984bb53f46a1
Z ed92d59f35c33d93aa0b00d0344b6f87
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
62009565d2f2a2c4d347e1da0d5b4ad43056742df47fd6ddb92e62f53a2b57f1
7eb5accb7cf937fc967dcd86da0af813fb18a2697348bd231fbefd3c09b930ab

View File

@@ -502,6 +502,11 @@ struct WalCkptInfo {
/*
** An open write-ahead log file is represented by an instance of the
** following object.
**
** writeLock:
** This is usually set to 1 whenever the WRITER lock is held. However,
** if it is set to 2, then the WRITER lock is held but must be released
** by walHandleException() if a SEH exception is thrown.
*/
struct Wal {
sqlite3_vfs *pVfs; /* The VFS used to create pDbFd */
@@ -2413,7 +2418,9 @@ static int walHandleException(Wal *pWal){
static const int S = 1;
static const int E = (1<<SQLITE_SHM_NLOCK);
int ii;
u32 mUnlock = pWal->lockMask & ~(
u32 mUnlock;
if( pWal->writeLock==2 ) pWal->writeLock = 0;
mUnlock = pWal->lockMask & ~(
(pWal->readLock<0 ? 0 : (S << WAL_READ_LOCK(pWal->readLock)))
| (pWal->writeLock ? (E << WAL_WRITE_LOCK) : 0)
| (pWal->ckptLock ? (E << WAL_CKPT_LOCK) : 0)
@@ -2685,7 +2692,12 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){
if( bWriteLock
|| SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1))
){
pWal->writeLock = 1;
/* If the write-lock was just obtained, set writeLock to 2 instead of
** the usual 1. This causes walIndexPage() to behave as if the
** write-lock were held (so that it allocates new pages as required),
** and walHandleException() to unlock the write-lock if a SEH exception
** is thrown. */
if( !bWriteLock ) pWal->writeLock = 2;
if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
badHdr = walIndexTryHdr(pWal, pChanged);
if( badHdr ){

View File

@@ -110,6 +110,7 @@ testfixture_nb done {
db eval {
COMMIT
}
db close
}
after 500 {set ok 1}
@@ -154,6 +155,7 @@ testfixture_nb done {
db eval {
COMMIT
}
db close
}
after 500 {set ok 1}
@@ -194,6 +196,7 @@ testfixture_nb done {
db eval {
COMMIT
}
db close
}
after 500 {set ok 1}
@@ -216,6 +219,7 @@ testfixture_nb done {
db eval {
COMMIT
}
db close
}
after 500 {set ok 1}