]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enable this branch to run both with and without the -DSQLITE_USE_SEH option.
authordrh <>
Thu, 19 Aug 2021 23:10:57 +0000 (23:10 +0000)
committerdrh <>
Thu, 19 Aug 2021 23:10:57 +0000 (23:10 +0000)
FossilOrigin-Name: 840e0a14ebc4a85d4ede0223287d4c1e4465e9f20c3c43bfc74775dddec1fa8f

manifest
manifest.uuid
src/wal.c

index aa4b2f12768f212dd786d85460cfb7fcc7fcef45..66ae90556b21780c232253ec5671cedd84b6ce2b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C If\sSQLITE_USE_SEH\sis\sdefined,\shandle\sstructured-exceptions\sthrown\sby\sMSVC\sbuilds\sif\sthe\s*-shm\sfile\smapping\sis\saccessed\safter\sit\sbecomes\sinvalid\sfor\ssome\sreason.
-D 2021-08-19T21:01:15.043
+C Enable\sthis\sbranch\sto\srun\sboth\swith\sand\swithout\sthe\s-DSQLITE_USE_SEH\soption.
+D 2021-08-19T23:10:57.409
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -628,7 +628,7 @@ F src/vdbetrace.c 666c6fd9f1b62be6999e072a45b913e3c2c3518bc60dfd4d54fe304130acb7
 F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
 F src/vtab.c 88404ac1517903b3eb2abe256772ee95bb09f81ac0a17e13afe5d467df4de4ee
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c dd9ca83fcd91eb237790c18e972f8f2fd30cf86848d6fa9fc09da25e8acf56ae
+F src/wal.c c07f7f1301f2af98e2ae83b5bde451b715da14ca88a355f85a7d4656f8f295c3
 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
 F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac
 F src/where.c 99b6e13664a7bd9a553c554978d0e253066995dade621f44cffa8928c8b493b5
@@ -1921,10 +1921,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 13abba0941a724eb62455650976b03678e4455b6b3090c84a2ab2f4a7656b4d8
-R f5105d1628b1a51745c8bcb5cc4af959
-T *branch * wal-shm-exceptions
-T *sym-wal-shm-exceptions *
-T -sym-trunk *
-U dan
-Z 55cb3a3675f7aa624d05737d0648760c
+P 5c5fa47076c5da25ca92248df3a4c11b90a0225a07f05d7220fa95d9bbb36f43
+R 7dea1ca77fe483a4591a9d63bfe86a5f
+U drh
+Z 84658daaaacd80f58fddb8eaeaf9e417
index 7c3a0bb78cf66b74840aab92daf64f2ceb16b8d4..5bfd9ee3815a034d9a671fb51acecb296aee9e76 100644 (file)
@@ -1 +1 @@
-5c5fa47076c5da25ca92248df3a4c11b90a0225a07f05d7220fa95d9bbb36f43
\ No newline at end of file
+840e0a14ebc4a85d4ede0223287d4c1e4465e9f20c3c43bfc74775dddec1fa8f
\ No newline at end of file
index c8cf4cc1b3284e4b2c2cd7ef7e9d390a07b45d5b..9a4451a09155b659169a7ec07bbff3467ac19f93 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -624,8 +624,8 @@ struct WalIterator {
 # define SEH_TRY    __try { \
    assert( walAssertLockmask(pWal) && pWal->nSehTry==0 ); TESTONLY(pWal->nSehTry++);
 
-# define SEH_EXCEPT TESTONLY(pWal->nSehTry--); assert( pWal->nSehTry==0 ); \
-   } __except( sehExceptionFilter(pWal, GetExceptionCode()) )
+# define SEH_EXCEPT(X) TESTONLY(pWal->nSehTry--); assert( pWal->nSehTry==0 ); \
+   } __except( sehExceptionFilter(pWal, GetExceptionCode()) ){ X }
 
 # define SEH_INJECT_FAULT sehInjectFault(pWal) 
 
@@ -650,10 +650,13 @@ static void sehInjectFault(Wal *pWal){
  }
 }
 
+#define SEH_FREE_ON_ERROR(X)  pWal->pFree = X
+
 #else
 # define SEH_TRY
-# define SEH_EXCEPT if(0)
+# define SEH_EXCEPT(X)
 # define SEH_INJECT_FAULT
+# define SEH_FREE_ON_ERROR(X)
 #endif /* ifdef SQLITE_USE_SEH */
 
 
@@ -1365,7 +1368,8 @@ static int walIndexRecover(Wal *pWal){
 
     /* Malloc a buffer to read frames into. */
     szFrame = szPage + WAL_FRAME_HDRSIZE;
-    pWal->pFree = aFrame = (u8 *)sqlite3_malloc64(szFrame + WALINDEX_PGSZ);
+    aFrame = (u8 *)sqlite3_malloc64(szFrame + WALINDEX_PGSZ);
+    SEH_FREE_ON_ERROR(aFrame);
     if( !aFrame ){
       rc = SQLITE_NOMEM_BKPT;
       goto recovery_error;
@@ -1444,7 +1448,7 @@ static int walIndexRecover(Wal *pWal){
     }
 
     sqlite3_free(aFrame);
-    pWal->pFree = 0;
+    SEH_FREE_ON_ERROR(0);
   }
 
 finished:
@@ -1863,7 +1867,7 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
   memset(p, 0, nByte);
   p->nSegment = nSegment;
   aTmp = (ht_slot*)&(((u8*)p)[nByte]);
-  pWal->pFree = p;
+  SEH_FREE_ON_ERROR(p);
 
   for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
     WalHashLoc sLoc;
@@ -1896,7 +1900,8 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
 
   if( rc!=SQLITE_OK ){
     walIteratorFree(p);
-    pWal->pFree = p = 0;
+    p = 0;
+    SEH_FREE_ON_ERROR(0);
   }
   *pp = p;
   return rc;
@@ -2261,9 +2266,11 @@ static int walCheckpoint(
   }
 
  walcheckpoint_out:
+#ifdef SQLITE_USE_SEH
   assert( pWal->pFree==(void*)pIter );
-  walIteratorFree(pIter);
   pWal->pFree = 0;
+#endif
+  walIteratorFree(pIter);
   return rc;
 }
 
@@ -2980,7 +2987,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
 ** invalid in SQLITE_USE_SEH builds. It is used as follows:
 **
 **   SEH_TRY { ... }
-**   SEH_EXCEPT { rc = walHandleException(pWal); }
+**   SEH_EXCEPT( rc = walHandleException(pWal); )
 **
 ** This function does three things:
 **
@@ -3113,9 +3120,7 @@ int sqlite3WalSnapshotRecover(Wal *pWal){
       SEH_TRY {
         rc = walSnapshotRecover(pWal, pBuf1, pBuf2);
       }
-      SEH_EXCEPT {
-        rc = SQLITE_IOERR;
-      }
+      SEH_EXCEPT( rc = SQLITE_IOERR; )
       pWal->ckptLock = 0;
     }
 
@@ -3251,9 +3256,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
   SEH_TRY {
     rc = walBeginReadTransaction(pWal, pChanged);
   }
-  SEH_EXCEPT { 
-    rc = walHandleException(pWal); 
-  }
+  SEH_EXCEPT( rc = walHandleException(pWal); )
   return rc;
 }
 
@@ -3386,7 +3389,7 @@ int sqlite3WalFindFrame(
   SEH_TRY {
     rc = walFindFrame(pWal, pgno, piRead);
   }
-  SEH_EXCEPT { rc = SQLITE_IOERR; }
+  SEH_EXCEPT( rc = SQLITE_IOERR; )
   return rc;
 }
 
@@ -3476,7 +3479,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){
       rc = SQLITE_BUSY_SNAPSHOT;
     }
   }
-  SEH_EXCEPT { rc = SQLITE_IOERR; }
+  SEH_EXCEPT( rc = SQLITE_IOERR; )
 
   if( rc!=SQLITE_OK ){
     walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
@@ -3543,9 +3546,7 @@ int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
       }
       if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
     }
-    SEH_EXCEPT {
-      rc = SQLITE_IOERR;
-    }
+    SEH_EXCEPT( rc = SQLITE_IOERR; )
   }
   return rc;
 }
@@ -3592,9 +3593,7 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
     SEH_TRY {
       walCleanupHash(pWal);
     }
-    SEH_EXCEPT { 
-      rc = SQLITE_IOERR; 
-    }
+    SEH_EXCEPT( rc = SQLITE_IOERR; )
   }
 
   return rc;
@@ -4015,9 +4014,7 @@ int sqlite3WalFrames(
   SEH_TRY {
     rc = walFrames(pWal, szPage, pList, nTruncate, isCommit, sync_flags);
   }
-  SEH_EXCEPT { 
-    rc = walHandleException(pWal);
-  }
+  SEH_EXCEPT( rc = walHandleException(pWal); )
   return rc;
 }
 
@@ -4126,9 +4123,7 @@ int sqlite3WalCheckpoint(
       if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);
     }
   }
-  SEH_EXCEPT { 
-    rc = walHandleException(pWal); 
-  }
+  SEH_EXCEPT( rc = walHandleException(pWal); )
 
   if( isChanged ){
     /* If a new wal-index header was loaded before the checkpoint was 
@@ -4320,9 +4315,7 @@ int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){
       }
     }
   }
-  SEH_EXCEPT {
-    rc = walHandleException(pWal);
-  }
+  SEH_EXCEPT( rc = walHandleException(pWal); )
   return rc;
 }