From 66422b57f9892262c0d5638a0c5d165658fcee43 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 11 Jul 2023 15:52:52 +0000 Subject: [PATCH] Get fault injection for testing working correctly. Other code clean-up. FossilOrigin-Name: ff492277ed00c1f637a5b4ccd6d8193ea22f6781f90073861588a2b7d5c045b7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/wal.c | 23 +++++++++++++++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 983bba5257..bd506d9ad1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sstyle\schanges\sto\sthe\sprevious\sMSVC\smakefile\schanges\son\sthis\sbranch. -D 2023-07-10T19:21:09.466 +C Get\sfault\sinjection\sfor\stesting\sworking\scorrectly.\s\sOther\scode\sclean-up. +D 2023-07-11T15:52:52.116 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -719,7 +719,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8 F src/vdbevtab.c aae4bd769410eb7e1d02c42613eec961d514459b1c3c1c63cfc84e92a137daac F src/vtab.c 1ecf8c3745d29275688d583e12822fa984d421e0286b5ef50c137bc3bf6d7a64 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c b4668b94644c79bd9e44ba0aacaeb32631413d1ccee72e67606443a30cc6e56e +F src/wal.c e4bfb243cc1f6f89c7fba5dd8872ae38a8c1dcc760c276dbb164edb7290072a6 F src/wal.h 04a9e53121d5076f2a173b0f2facb39d33047093fee71bd3bbe6b1f6f1f5fd4b F src/walker.c 7c7ea0115345851c3da4e04e2e239a29983b61fb5b038b94eede6aba462640e2 F src/where.c 2dc708cf8b6a691fb79f16bbc46567497ee6f991043318d421e294b2da114d93 @@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0e67a82f6cfe681d4676ac5c92d92e95b9dcc3198df21516bccdde002f5e52ae -R 2485a85a908a05b5fd0644b2f7fd3722 -U mistachkin -Z 5b8cb43f82a279de421ae118ca8d7765 +P 4c950872c870a5968fa4cb8840cf60569a66c0e508811ee79992825ec9c02da3 +R 966aa4944515db815a2a3b1d2b09adbd +U drh +Z 4e4c72cb034026cb3cf7caeaeea5ca69 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3f7af51b45..066d2d9ef2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4c950872c870a5968fa4cb8840cf60569a66c0e508811ee79992825ec9c02da3 \ No newline at end of file +ff492277ed00c1f637a5b4ccd6d8193ea22f6781f90073861588a2b7d5c045b7 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 0cb4f0344a..6c153d65ba 100644 --- a/src/wal.c +++ b/src/wal.c @@ -528,15 +528,13 @@ struct Wal { u32 iReCksum; /* On commit, recalculate checksums from here */ const char *zWalName; /* Name of WAL file */ u32 nCkpt; /* Checkpoint sequence counter in the wal-header */ -# ifdef SQLITE_DEBUG - int nSehTry; /* Number of nested SEH_TRY{} blocks */ -# endif #ifdef SQLITE_USE_SEH u32 lockMask; /* Mask of locks held */ void *pFree; /* Pointer to sqlite3_free() if exception thrown */ int iSysErrno; /* System error code following exception */ #endif #ifdef SQLITE_DEBUG + int nSehTry; /* Number of nested SEH_TRY{} blocks */ u8 lockError; /* True if a locking error has occurred */ #endif #ifdef SQLITE_ENABLE_SNAPSHOT @@ -618,19 +616,32 @@ struct WalIterator { sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \ ) +/* +** Structured Exception Handling (SEH) is a Windows-specific technique +** for catching exceptions raised while accessing memory-mapped files. +** +** The -DSQLITE_USE_SEH compile-time option means to use SEH to catch and +** deal with system-level errors that arise during WAL -shm file processing. +** Without this compile-time option, any system-level faults that appear +** while accessing the memory-mapped -shm file will cause a process-wide +** signal to be deliver, which will more than likely cause the entire +** process to exit. +*/ #ifdef SQLITE_USE_SEH - #include +/* Beginning of a block of code in which an exception might occur */ # define SEH_TRY __try { \ assert( walAssertLockmask(pWal) && pWal->nSehTry==0 ); \ VVA_ONLY(pWal->nSehTry++); +/* The end of a block of code in which an exception might occur */ # define SEH_EXCEPT(X) \ VVA_ONLY(pWal->nSehTry--); \ assert( pWal->nSehTry==0 ); \ } __except( sehExceptionFilter(pWal, GetExceptionCode(), GetExceptionInformation() ) ){ X } +/* Simulate a memory-mapping fault in the -shm file for testing purposes */ # define SEH_INJECT_FAULT sehInjectFault(pWal) /* @@ -662,10 +673,10 @@ static void sehInjectFault(Wal *pWal){ res = sqlite3FaultSim(650); if( res!=0 ){ - ULONG aArg[3]; + ULONG_PTR aArg[3]; aArg[0] = 0; aArg[1] = 0; - aArg[2] = (ULONG)res; + aArg[2] = (ULONG_PTR)res; RaiseException(EXCEPTION_IN_PAGE_ERROR, 0, 3, (const ULONG_PTR*)aArg); } } -- 2.47.2