-C Fix\sa\sminor\sover-allocation\sof\sheap\smemory\sin\swal.c.
-D 2025-10-27T11:39:07.586
+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-27T14:24:02.623
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3
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.h 4c247cdb6d407c75186c94a1e84d5a22cbae4adcec93fcae8d2bc1f956fd1f19
F src/pager.c 113f9149092ccff6cf90e97c2611200e5a237f13d26c394bc9fd933377852764
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 6ff9ecb89d769bc2a27f8a57130f28ec7478979d3e35ba765c16017b5bdf775d
-R 4bcc5da65154a62685074a5874c60e20
-U dan
-Z b3c584459b21dffccf981eba99e95d81
+P 1803cb9bb6a13fb66956f729066b6eae64c3a1c0715102fb1a9994e395c12ba9
+R fe548fc30b94a215f07ed244ccaa81d7
+T *branch * broken-lock-defense-1
+T *sym-broken-lock-defense-1 *
+T -sym-trunk *
+U drh
+Z 5c21161c3da333e4ec22a3b174b7937b
# Remove this line to create a well-formed Fossil manifest.
return rc;
}
+/* Forward reference */
+static int unixIsSharingShmNode(unixFile*);
+
/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
pInode->nLock++;
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
** same process is still holding a shared lock. */
rc = SQLITE_BUSY;
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.