Add compiler hints to disable TSAN for the routines that access the -shm

file header in WAL mode using a double-read with memory barrier.

FossilOrigin-Name: 3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde
This commit is contained in:
drh 2020-05-19 15:51:10 +00:00
parent 10757ed0ca
commit 5a8cd2e40c
3 changed files with 23 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C In\sos_win.c,\savoid\scalling\ssqlite3_uri_boolean()\son\sanything\sother\sthan\sa\smain-db\sfilename.
D 2020-05-19T15:40:07.909
C Add\scompiler\shints\sto\sdisable\sTSAN\sfor\sthe\sroutines\sthat\saccess\sthe\s-shm\nfile\sheader\sin\sWAL\smode\susing\sa\sdouble-read\swith\smemory\sbarrier.
D 2020-05-19T15:51:10.216
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -617,7 +617,7 @@ F src/vdbetrace.c fa3bf238002f0bbbdfb66cc8afb0cea284ff9f148d6439bc1f6f2b4c3b7143
F src/vdbevtab.c ee5b4c902fdda2230f9503ac7b84c6d614c91e8f6f4dc1633e2e8dfef8ffb144
F src/vtab.c 7b452592ed2ee95dedb1f323d557cebede5a6f3b4558b21a5dca527e6ae9b12c
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c fc763af2c20d1770e872378b28031c100b52061ec47599f38499cf4bd4977284
F src/wal.c 17ea0a319d3ead17ef3b16aa30f10f2626056893effea7e609a20a6661ffec1b
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c 7c429c694abd12413a5c17aec9f47cfe9eba6807e6b0a32df883e8e3a14835ed
F src/where.c 9546c82056e8cdb27291f98cf1adca5d271240b399bb97b32f77fc2bea6146c9
@ -1866,7 +1866,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 1d1293c25abdd4b0fca64e5b1d0a118e2f339635dbc89422c0c2463fbf9ee27f
R 77702df5e982362c55239f265fbb9eea
U dan
Z 7af2360054e2377399137e1a09b7af22
P cb0a18e64f8d81c2ada9f698faaf5ca68a0666687bf6f3abc860324cb1997463
R 8462379efa542a8195db58fd9ef94a35
U drh
Z 5f8f2ff4f8e169f83e77c91d9875e042

View File

@ -1 +1 @@
cb0a18e64f8d81c2ada9f698faaf5ca68a0666687bf6f3abc860324cb1997463
3117c1b5a9e348fd8d16ba9d03fdafaad8514567fb3403f72b86d6162ad40bde

View File

@ -699,12 +699,25 @@ static void walShmBarrier(Wal *pWal){
}
}
/*
** Add the SQLITE_NO_TSAN as part of the return-type of a function
** definition as a hint that the function contains constructs that
** might give false-positive TSAN warnings.
**
** See tag-20200519-1.
*/
#if defined(__clang__) && !defined(SQLITE_NO_TSAN)
# define SQLITE_NO_TSAN __attribute__((no_sanitize_thread))
#else
# define SQLITE_NO_TSAN
#endif
/*
** Write the header information in pWal->hdr into the wal-index.
**
** The checksum on pWal->hdr is updated before it is written.
*/
static void walIndexWriteHdr(Wal *pWal){
static SQLITE_NO_TSAN void walIndexWriteHdr(Wal *pWal){
volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
const int nCksum = offsetof(WalIndexHdr, aCksum);
@ -2141,7 +2154,7 @@ int sqlite3WalClose(
** If the checksum cannot be verified return non-zero. If the header
** is read successfully and the checksum verified, return zero.
*/
static int walIndexTryHdr(Wal *pWal, int *pChanged){
static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){
u32 aCksum[2]; /* Checksum on the header content */
WalIndexHdr h1, h2; /* Two copies of the header content */
WalIndexHdr volatile *aHdr; /* Header in shared memory */