From: drh Date: Thu, 10 Sep 2009 17:45:00 +0000 (+0000) Subject: Add assert() statement to verify that new mutexes are not allocated when X-Git-Tag: fts3-refactor~193 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fe5bdb36ab34ed58b37c7c1c3b547adeb8b8bbf8;p=thirdparty%2Fsqlite.git Add assert() statement to verify that new mutexes are not allocated when the mutex subsystem is uninitialized. FossilOrigin-Name: 1183c533571bc9c7ce56102b718f3e4f4e78019e --- diff --git a/manifest b/manifest index 5823e78219..92eba45d9a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\sproblem\swith\sthe\ssqlite3VdbeMayAbort()\sassert\sfailing\sfollowing\san\sOOM. -D 2009-09-10T16:14:51 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Add\sassert()\sstatement\sto\sverify\sthat\snew\smutexes\sare\snot\sallocated\swhen\nthe\smutex\ssubsystem\sis\suninitialized. +D 2009-09-10T17:45:00 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -134,7 +137,7 @@ F src/mem2.c d02bd6a5b34f2d59012a852615621939d9c09548 F src/mem3.c 67153ec933e08b70714055e872efb58a6b287939 F src/mem5.c 4837b795ebdecc0cfe1522cd0c8b2c5d84ea490d F src/memjournal.c e68cb5f7e828b84d5bf2ea16c5d87f1ed7e9fe7f -F src/mutex.c 73899d158560117c02909b6e9ffe2bad2560a817 +F src/mutex.c 60cd6d854e1c5dbedd9928815c00d63ec24283a9 F src/mutex.h 9e686e83a88838dac8b9c51271c651e833060f1e F src/mutex_noop.c f5a07671f25a1a9bd7c10ad7107bc2585446200f F src/mutex_os2.c 6b5a74f812082a8483c3df05b47bbaac2424b9a0 @@ -750,7 +753,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f2a9ee722c568e73f2a08fb6a2886719850f2923 -R 0b14469668328c64842d4f0eb53973f8 -U dan -Z db4c68226e60cda5c9b94fd0b4485956 +P b3027863505fa8edf355f3f5eea4502ef365175e +R 08804fe3d59d9c44cb7b080e511dfef2 +U drh +Z 0e4a69ed44dd7c7502a8c79038532167 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFKqTsgoxKgR168RlERAn1TAJ9uG3gx/c3HhgDhOPqRUn7M66SIOwCggh6Q +/YiheptxazPExELwQLXw9SU= +=OssI +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index d7676001d4..3235cec167 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b3027863505fa8edf355f3f5eea4502ef365175e \ No newline at end of file +1183c533571bc9c7ce56102b718f3e4f4e78019e \ No newline at end of file diff --git a/src/mutex.c b/src/mutex.c index 9c7cdd4ab1..6ceb46b070 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -18,6 +18,16 @@ */ #include "sqliteInt.h" +#ifdef SQLITE_DEBUG +/* +** For debugging purposes, record when the mutex subsystem is initialized +** and uninitialized so that we can assert() if there is an attempt to +** allocate a mutex while the system is uninitialized. +*/ +static SQLITE_WSD int mutexIsInit = 0; +#endif /* SQLITE_DEBUG */ + + #ifndef SQLITE_MUTEX_OMIT /* ** Initialize the mutex system. @@ -42,6 +52,10 @@ int sqlite3MutexInit(void){ rc = sqlite3GlobalConfig.mutex.xMutexInit(); } +#ifdef SQLITE_DEBUG + GLOBAL(int, mutexIsInit) = 1; +#endif + return rc; } @@ -54,6 +68,11 @@ int sqlite3MutexEnd(void){ if( sqlite3GlobalConfig.mutex.xMutexEnd ){ rc = sqlite3GlobalConfig.mutex.xMutexEnd(); } + +#ifdef SQLITE_DEBUG + GLOBAL(int, mutexIsInit) = 0; +#endif + return rc; } @@ -71,6 +90,7 @@ sqlite3_mutex *sqlite3MutexAlloc(int id){ if( !sqlite3GlobalConfig.bCoreMutex ){ return 0; } + assert( GLOBAL(int, mutexIsInit) ); return sqlite3GlobalConfig.mutex.xMutexAlloc(id); }