mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-21 13:38:01 +03:00
Implement an experimental defensive measure to try to prevent the -wal and
-shm files of an active WAL-mode database connection from being deleted out from under the database connection in the case where the database SHARED lock has been released by an accidental call to close() in a different thread, or similar. FossilOrigin-Name: ed1b9206640f66cb8abff444809ccab8a4a5157b5c90e9aacddc422210e63423
This commit is contained in:
17
manifest
17
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\sminor\sover-allocation\sof\sheap\smemory\sin\swal.c.
|
C Implement\san\sexperimental\sdefensive\smeasure\sto\stry\sto\sprevent\sthe\s-wal\sand\n-shm\sfiles\sof\san\sactive\sWAL-mode\sdatabase\sconnection\sfrom\sbeing\sdeleted\sout\nfrom\sunder\sthe\sdatabase\sconnection\sin\sthe\scase\swhere\sthe\sdatabase\sSHARED\nlock\shas\sbeen\sreleased\sby\san\saccidental\scall\sto\sclose()\sin\sa\sdifferent\nthread,\sor\ssimilar.
|
||||||
D 2025-10-27T11:39:07.586
|
D 2025-10-27T14:24:02.623
|
||||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
@@ -720,7 +720,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
|
|||||||
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
|
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
|
||||||
F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3
|
F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3
|
||||||
F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2
|
F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2
|
||||||
F src/os_unix.c bbd3ec01b2023bc41b532666533e087feea457c595d1b63284c8acc8929ea7d5
|
F src/os_unix.c 02cbe89914a66f90913ffd96b366176d8a1e65b158cdf58f24734b55c472a308
|
||||||
F src/os_win.c 27617f334168644b542c9d58ac6e5f051b318136273e78d243384b4eca2df6b3
|
F src/os_win.c 27617f334168644b542c9d58ac6e5f051b318136273e78d243384b4eca2df6b3
|
||||||
F src/os_win.h 4c247cdb6d407c75186c94a1e84d5a22cbae4adcec93fcae8d2bc1f956fd1f19
|
F src/os_win.h 4c247cdb6d407c75186c94a1e84d5a22cbae4adcec93fcae8d2bc1f956fd1f19
|
||||||
F src/pager.c 113f9149092ccff6cf90e97c2611200e5a237f13d26c394bc9fd933377852764
|
F src/pager.c 113f9149092ccff6cf90e97c2611200e5a237f13d26c394bc9fd933377852764
|
||||||
@@ -2171,8 +2171,11 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
|
|||||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||||
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
|
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 6ff9ecb89d769bc2a27f8a57130f28ec7478979d3e35ba765c16017b5bdf775d
|
P 1803cb9bb6a13fb66956f729066b6eae64c3a1c0715102fb1a9994e395c12ba9
|
||||||
R 4bcc5da65154a62685074a5874c60e20
|
R fe548fc30b94a215f07ed244ccaa81d7
|
||||||
U dan
|
T *branch * broken-lock-defense-1
|
||||||
Z b3c584459b21dffccf981eba99e95d81
|
T *sym-broken-lock-defense-1 *
|
||||||
|
T -sym-trunk *
|
||||||
|
U drh
|
||||||
|
Z 5c21161c3da333e4ec22a3b174b7937b
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
branch trunk
|
branch broken-lock-defense-1
|
||||||
tag trunk
|
tag broken-lock-defense-1
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1803cb9bb6a13fb66956f729066b6eae64c3a1c0715102fb1a9994e395c12ba9
|
ed1b9206640f66cb8abff444809ccab8a4a5157b5c90e9aacddc422210e63423
|
||||||
|
|||||||
@@ -1832,6 +1832,9 @@ static int unixFileLock(unixFile *pFile, struct flock *pLock){
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Forward reference */
|
||||||
|
static int unixIsSharingShmNode(unixFile*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Lock the file with the lock specified by parameter eFileLock - one
|
** Lock the file with the lock specified by parameter eFileLock - one
|
||||||
** of the following:
|
** of the following:
|
||||||
@@ -2020,7 +2023,9 @@ static int unixLock(sqlite3_file *id, int eFileLock){
|
|||||||
pInode->nLock++;
|
pInode->nLock++;
|
||||||
pInode->nShared = 1;
|
pInode->nShared = 1;
|
||||||
}
|
}
|
||||||
}else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){
|
}else if( (eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1)
|
||||||
|
|| unixIsSharingShmNode(pFile)
|
||||||
|
){
|
||||||
/* We are trying for an exclusive lock but another thread in this
|
/* We are trying for an exclusive lock but another thread in this
|
||||||
** same process is still holding a shared lock. */
|
** same process is still holding a shared lock. */
|
||||||
rc = SQLITE_BUSY;
|
rc = SQLITE_BUSY;
|
||||||
@@ -4640,6 +4645,33 @@ static int unixFcntlExternalReader(unixFile *pFile, int *piOut){
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If pFile has a -shm file open and it is sharing that file with some
|
||||||
|
** other connection, either in the same process or in a separate process,
|
||||||
|
** then return true. Return false if either pFile does not have a -shm
|
||||||
|
** file open or if it is the only connection to that -shm file across the
|
||||||
|
** entire system.
|
||||||
|
*/
|
||||||
|
static int unixIsSharingShmNode(unixFile *pFile){
|
||||||
|
int rc;
|
||||||
|
unixShmNode *pShmNode;
|
||||||
|
if( pFile->pShm==0 ) return 0;
|
||||||
|
pShmNode = pFile->pShm->pShmNode;
|
||||||
|
rc = 1;
|
||||||
|
unixEnterMutex();
|
||||||
|
if( pShmNode->nRef==1 ){
|
||||||
|
struct flock lock;
|
||||||
|
lock.l_whence = SEEK_SET;
|
||||||
|
lock.l_start = UNIX_SHM_DMS;
|
||||||
|
lock.l_len = 1;
|
||||||
|
lock.l_type = F_WRLCK;
|
||||||
|
if( osFcntl(pShmNode->hShm, F_GETLK, &lock)==0 && lock.l_type==F_UNLCK ){
|
||||||
|
rc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unixLeaveMutex();
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Apply posix advisory locks for all bytes from ofst through ofst+n-1.
|
** Apply posix advisory locks for all bytes from ofst through ofst+n-1.
|
||||||
|
|||||||
Reference in New Issue
Block a user