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

Enable this branch to run both with and without the -DSQLITE_USE_SEH option.

FossilOrigin-Name: 840e0a14ebc4a85d4ede0223287d4c1e4465e9f20c3c43bfc74775dddec1fa8f
This commit is contained in:
drh
2021-08-19 23:10:57 +00:00
parent 8aa22ffe98
commit aecd7f9d75
3 changed files with 33 additions and 43 deletions

View File

@@ -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. C Enable\sthis\sbranch\sto\srun\sboth\swith\sand\swithout\sthe\s-DSQLITE_USE_SEH\soption.
D 2021-08-19T21:01:15.043 D 2021-08-19T23:10:57.409
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -628,7 +628,7 @@ F src/vdbetrace.c 666c6fd9f1b62be6999e072a45b913e3c2c3518bc60dfd4d54fe304130acb7
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
F src/vtab.c 88404ac1517903b3eb2abe256772ee95bb09f81ac0a17e13afe5d467df4de4ee F src/vtab.c 88404ac1517903b3eb2abe256772ee95bb09f81ac0a17e13afe5d467df4de4ee
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c dd9ca83fcd91eb237790c18e972f8f2fd30cf86848d6fa9fc09da25e8acf56ae F src/wal.c c07f7f1301f2af98e2ae83b5bde451b715da14ca88a355f85a7d4656f8f295c3
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac
F src/where.c 99b6e13664a7bd9a553c554978d0e253066995dade621f44cffa8928c8b493b5 F src/where.c 99b6e13664a7bd9a553c554978d0e253066995dade621f44cffa8928c8b493b5
@@ -1921,10 +1921,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 13abba0941a724eb62455650976b03678e4455b6b3090c84a2ab2f4a7656b4d8 P 5c5fa47076c5da25ca92248df3a4c11b90a0225a07f05d7220fa95d9bbb36f43
R f5105d1628b1a51745c8bcb5cc4af959 R 7dea1ca77fe483a4591a9d63bfe86a5f
T *branch * wal-shm-exceptions U drh
T *sym-wal-shm-exceptions * Z 84658daaaacd80f58fddb8eaeaf9e417
T -sym-trunk *
U dan
Z 55cb3a3675f7aa624d05737d0648760c

View File

@@ -1 +1 @@
5c5fa47076c5da25ca92248df3a4c11b90a0225a07f05d7220fa95d9bbb36f43 840e0a14ebc4a85d4ede0223287d4c1e4465e9f20c3c43bfc74775dddec1fa8f

View File

@@ -624,8 +624,8 @@ struct WalIterator {
# define SEH_TRY __try { \ # define SEH_TRY __try { \
assert( walAssertLockmask(pWal) && pWal->nSehTry==0 ); TESTONLY(pWal->nSehTry++); assert( walAssertLockmask(pWal) && pWal->nSehTry==0 ); TESTONLY(pWal->nSehTry++);
# define SEH_EXCEPT TESTONLY(pWal->nSehTry--); assert( pWal->nSehTry==0 ); \ # define SEH_EXCEPT(X) TESTONLY(pWal->nSehTry--); assert( pWal->nSehTry==0 ); \
} __except( sehExceptionFilter(pWal, GetExceptionCode()) ) } __except( sehExceptionFilter(pWal, GetExceptionCode()) ){ X }
# define SEH_INJECT_FAULT sehInjectFault(pWal) # 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 #else
# define SEH_TRY # define SEH_TRY
# define SEH_EXCEPT if(0) # define SEH_EXCEPT(X)
# define SEH_INJECT_FAULT # define SEH_INJECT_FAULT
# define SEH_FREE_ON_ERROR(X)
#endif /* ifdef SQLITE_USE_SEH */ #endif /* ifdef SQLITE_USE_SEH */
@@ -1365,7 +1368,8 @@ static int walIndexRecover(Wal *pWal){
/* Malloc a buffer to read frames into. */ /* Malloc a buffer to read frames into. */
szFrame = szPage + WAL_FRAME_HDRSIZE; 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 ){ if( !aFrame ){
rc = SQLITE_NOMEM_BKPT; rc = SQLITE_NOMEM_BKPT;
goto recovery_error; goto recovery_error;
@@ -1444,7 +1448,7 @@ static int walIndexRecover(Wal *pWal){
} }
sqlite3_free(aFrame); sqlite3_free(aFrame);
pWal->pFree = 0; SEH_FREE_ON_ERROR(0);
} }
finished: finished:
@@ -1863,7 +1867,7 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
memset(p, 0, nByte); memset(p, 0, nByte);
p->nSegment = nSegment; p->nSegment = nSegment;
aTmp = (ht_slot*)&(((u8*)p)[nByte]); 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++){ for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){
WalHashLoc sLoc; WalHashLoc sLoc;
@@ -1896,7 +1900,8 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
walIteratorFree(p); walIteratorFree(p);
pWal->pFree = p = 0; p = 0;
SEH_FREE_ON_ERROR(0);
} }
*pp = p; *pp = p;
return rc; return rc;
@@ -2261,9 +2266,11 @@ static int walCheckpoint(
} }
walcheckpoint_out: walcheckpoint_out:
#ifdef SQLITE_USE_SEH
assert( pWal->pFree==(void*)pIter ); assert( pWal->pFree==(void*)pIter );
walIteratorFree(pIter);
pWal->pFree = 0; pWal->pFree = 0;
#endif
walIteratorFree(pIter);
return rc; 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: ** invalid in SQLITE_USE_SEH builds. It is used as follows:
** **
** SEH_TRY { ... } ** SEH_TRY { ... }
** SEH_EXCEPT { rc = walHandleException(pWal); } ** SEH_EXCEPT( rc = walHandleException(pWal); )
** **
** This function does three things: ** This function does three things:
** **
@@ -3113,9 +3120,7 @@ int sqlite3WalSnapshotRecover(Wal *pWal){
SEH_TRY { SEH_TRY {
rc = walSnapshotRecover(pWal, pBuf1, pBuf2); rc = walSnapshotRecover(pWal, pBuf1, pBuf2);
} }
SEH_EXCEPT { SEH_EXCEPT( rc = SQLITE_IOERR; )
rc = SQLITE_IOERR;
}
pWal->ckptLock = 0; pWal->ckptLock = 0;
} }
@@ -3251,9 +3256,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
SEH_TRY { SEH_TRY {
rc = walBeginReadTransaction(pWal, pChanged); rc = walBeginReadTransaction(pWal, pChanged);
} }
SEH_EXCEPT { SEH_EXCEPT( rc = walHandleException(pWal); )
rc = walHandleException(pWal);
}
return rc; return rc;
} }
@@ -3386,7 +3389,7 @@ int sqlite3WalFindFrame(
SEH_TRY { SEH_TRY {
rc = walFindFrame(pWal, pgno, piRead); rc = walFindFrame(pWal, pgno, piRead);
} }
SEH_EXCEPT { rc = SQLITE_IOERR; } SEH_EXCEPT( rc = SQLITE_IOERR; )
return rc; return rc;
} }
@@ -3476,7 +3479,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){
rc = SQLITE_BUSY_SNAPSHOT; rc = SQLITE_BUSY_SNAPSHOT;
} }
} }
SEH_EXCEPT { rc = SQLITE_IOERR; } SEH_EXCEPT( rc = SQLITE_IOERR; )
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1); 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); if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
} }
SEH_EXCEPT { SEH_EXCEPT( rc = SQLITE_IOERR; )
rc = SQLITE_IOERR;
}
} }
return rc; return rc;
} }
@@ -3592,9 +3593,7 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
SEH_TRY { SEH_TRY {
walCleanupHash(pWal); walCleanupHash(pWal);
} }
SEH_EXCEPT { SEH_EXCEPT( rc = SQLITE_IOERR; )
rc = SQLITE_IOERR;
}
} }
return rc; return rc;
@@ -4015,9 +4014,7 @@ int sqlite3WalFrames(
SEH_TRY { SEH_TRY {
rc = walFrames(pWal, szPage, pList, nTruncate, isCommit, sync_flags); rc = walFrames(pWal, szPage, pList, nTruncate, isCommit, sync_flags);
} }
SEH_EXCEPT { SEH_EXCEPT( rc = walHandleException(pWal); )
rc = walHandleException(pWal);
}
return rc; return rc;
} }
@@ -4126,9 +4123,7 @@ int sqlite3WalCheckpoint(
if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill); if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);
} }
} }
SEH_EXCEPT { SEH_EXCEPT( rc = walHandleException(pWal); )
rc = walHandleException(pWal);
}
if( isChanged ){ if( isChanged ){
/* If a new wal-index header was loaded before the checkpoint was /* 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 { SEH_EXCEPT( rc = walHandleException(pWal); )
rc = walHandleException(pWal);
}
return rc; return rc;
} }