1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Add assert() statement to verify that new mutexes are not allocated when

the mutex subsystem is uninitialized.

FossilOrigin-Name: 1183c533571bc9c7ce56102b718f3e4f4e78019e
This commit is contained in:
drh
2009-09-10 17:45:00 +00:00
parent f3677212e3
commit fe5bdb36ab
3 changed files with 38 additions and 8 deletions

View File

@@ -1,5 +1,8 @@
C Fix\sa\sproblem\swith\sthe\ssqlite3VdbeMayAbort()\sassert\sfailing\sfollowing\san\sOOM. -----BEGIN PGP SIGNED MESSAGE-----
D 2009-09-10T16:14:51 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.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8 F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -134,7 +137,7 @@ F src/mem2.c d02bd6a5b34f2d59012a852615621939d9c09548
F src/mem3.c 67153ec933e08b70714055e872efb58a6b287939 F src/mem3.c 67153ec933e08b70714055e872efb58a6b287939
F src/mem5.c 4837b795ebdecc0cfe1522cd0c8b2c5d84ea490d F src/mem5.c 4837b795ebdecc0cfe1522cd0c8b2c5d84ea490d
F src/memjournal.c e68cb5f7e828b84d5bf2ea16c5d87f1ed7e9fe7f F src/memjournal.c e68cb5f7e828b84d5bf2ea16c5d87f1ed7e9fe7f
F src/mutex.c 73899d158560117c02909b6e9ffe2bad2560a817 F src/mutex.c 60cd6d854e1c5dbedd9928815c00d63ec24283a9
F src/mutex.h 9e686e83a88838dac8b9c51271c651e833060f1e F src/mutex.h 9e686e83a88838dac8b9c51271c651e833060f1e
F src/mutex_noop.c f5a07671f25a1a9bd7c10ad7107bc2585446200f F src/mutex_noop.c f5a07671f25a1a9bd7c10ad7107bc2585446200f
F src/mutex_os2.c 6b5a74f812082a8483c3df05b47bbaac2424b9a0 F src/mutex_os2.c 6b5a74f812082a8483c3df05b47bbaac2424b9a0
@@ -750,7 +753,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P f2a9ee722c568e73f2a08fb6a2886719850f2923 P b3027863505fa8edf355f3f5eea4502ef365175e
R 0b14469668328c64842d4f0eb53973f8 R 08804fe3d59d9c44cb7b080e511dfef2
U dan U drh
Z db4c68226e60cda5c9b94fd0b4485956 Z 0e4a69ed44dd7c7502a8c79038532167
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFKqTsgoxKgR168RlERAn1TAJ9uG3gx/c3HhgDhOPqRUn7M66SIOwCggh6Q
/YiheptxazPExELwQLXw9SU=
=OssI
-----END PGP SIGNATURE-----

View File

@@ -1 +1 @@
b3027863505fa8edf355f3f5eea4502ef365175e 1183c533571bc9c7ce56102b718f3e4f4e78019e

View File

@@ -18,6 +18,16 @@
*/ */
#include "sqliteInt.h" #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 #ifndef SQLITE_MUTEX_OMIT
/* /*
** Initialize the mutex system. ** Initialize the mutex system.
@@ -42,6 +52,10 @@ int sqlite3MutexInit(void){
rc = sqlite3GlobalConfig.mutex.xMutexInit(); rc = sqlite3GlobalConfig.mutex.xMutexInit();
} }
#ifdef SQLITE_DEBUG
GLOBAL(int, mutexIsInit) = 1;
#endif
return rc; return rc;
} }
@@ -54,6 +68,11 @@ int sqlite3MutexEnd(void){
if( sqlite3GlobalConfig.mutex.xMutexEnd ){ if( sqlite3GlobalConfig.mutex.xMutexEnd ){
rc = sqlite3GlobalConfig.mutex.xMutexEnd(); rc = sqlite3GlobalConfig.mutex.xMutexEnd();
} }
#ifdef SQLITE_DEBUG
GLOBAL(int, mutexIsInit) = 0;
#endif
return rc; return rc;
} }
@@ -71,6 +90,7 @@ sqlite3_mutex *sqlite3MutexAlloc(int id){
if( !sqlite3GlobalConfig.bCoreMutex ){ if( !sqlite3GlobalConfig.bCoreMutex ){
return 0; return 0;
} }
assert( GLOBAL(int, mutexIsInit) );
return sqlite3GlobalConfig.mutex.xMutexAlloc(id); return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
} }