Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4221e628c1 | |||
| 5c870cb03c | |||
| b25754a62d | |||
| e7c4184348 | |||
| aa985b3208 | |||
| 3f44c65513 | |||
| acc8f7b24c | |||
| a4da3c17c3 | |||
| 89e57dd671 | |||
| db17a83295 | |||
| 4b3f0d6281 | |||
| 8bdc914af3 |
@@ -1,5 +1,5 @@
|
||||
C Capture\sAFL-generated\sfuzz\stests\sfor\sjson1.c\sinto\sthe\stest/fuzzdata4.db\sfile.
|
||||
D 2015-09-23T11:59:50.725
|
||||
C Merge\supdates\sfrom\strunk.
|
||||
D 2015-09-23T15:54:36.389
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in e1afa6fb2de2bddd50e0ddae8166c2ee9d69b301
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -296,7 +296,7 @@ F src/expr.c 3a76afcdac925294c39903b7002ddb9e5fd29863
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c 83e1baba999bed3144ea5a2143fc922edf51135f
|
||||
F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f
|
||||
F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9
|
||||
F src/global.c d824163680839be79b53204105a78e5be5d4ac4a
|
||||
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
|
||||
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
|
||||
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
|
||||
@@ -305,7 +305,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
|
||||
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
|
||||
F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012
|
||||
F src/loadext.c f0b66d28e377fd6c6d36cc9d92df1ff251ebee44
|
||||
F src/main.c e17fcffae4306a9b8334faf3bac80d7396850b54
|
||||
F src/main.c 9f196a4364270af28ab97c1d62046e56e32dd11d
|
||||
F src/malloc.c 3a37ce6979a40f499d8cea9e9ab4e8517854d35d
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987
|
||||
@@ -314,11 +314,11 @@ F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534
|
||||
F src/mem5.c 61eeb90134f9a5be6c2e68d8daae7628b25953fb
|
||||
F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85
|
||||
F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495
|
||||
F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c
|
||||
F src/mutex.c b0fbea2cda9f8e81444f5f1b4b9f07c1a904269e
|
||||
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
|
||||
F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4
|
||||
F src/mutex_unix.c 8cfa6e83c618d2fcae0fe63f4d2b5bb16b11a97a
|
||||
F src/mutex_w32.c 2e025e6642eaf27597403690980f560d1a91f62c
|
||||
F src/mutex_noop.c f03e26ba8258399da23b51234f6b6a97197c1900
|
||||
F src/mutex_unix.c a72043f2560147d8e85fe48a6aef682896deb3a0
|
||||
F src/mutex_w32.c 928c889408e3196f325d23fa4d115b3bc59d8eb6
|
||||
F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7
|
||||
F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
|
||||
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||
@@ -345,7 +345,7 @@ F src/shell.c 6332ef06db1390ef812cfdff1fc97b4fd76cdd42
|
||||
F src/sqlite.h.in 4e06cb5fed36736242c66237991db6f3e2395eb9
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
F src/sqlite3ext.h 64350bf36833a56ad675e27392a913f417c5c308
|
||||
F src/sqliteInt.h 5afc6e50402be1e0a870f28e1cd8b32eb9db590f
|
||||
F src/sqliteInt.h ed65bcb0a6a7c11978c8f75d5476d6edaa024e8d
|
||||
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
|
||||
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
|
||||
F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
|
||||
@@ -1388,7 +1388,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 7c7a3f3e9bc2f7a7334d8d6eae183d83f22097be
|
||||
R 64646de8f025fcbfbac14050e58f6d8a
|
||||
U drh
|
||||
Z 8d3625ca1ecc6df3eff60cf48fea0eb8
|
||||
P c9400ff167d9520119081c9b92436794dcd53d22 10a214fdb3c13b25e0bdd15c975c21c8890c47ee
|
||||
R b42897c3c8ae6a403b71a2f426cb59b5
|
||||
U mistachkin
|
||||
Z 6c86ab7133863d50d8bbe949c96c8dea
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
10a214fdb3c13b25e0bdd15c975c21c8890c47ee
|
||||
6b85f8cd4d87d616a3cb362647ae3869c45c2801
|
||||
@@ -174,6 +174,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
|
||||
128, /* szLookaside */
|
||||
500, /* nLookaside */
|
||||
{0,0,0,0,0,0,0,0}, /* m */
|
||||
(void*)0, /* pMutex */
|
||||
{0,0,0,0,0,0,0,0,0}, /* mutex */
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */
|
||||
(void*)0, /* pHeap */
|
||||
|
||||
+27
-3
@@ -171,7 +171,13 @@ int sqlite3_initialize(void){
|
||||
*/
|
||||
MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
|
||||
sqlite3_mutex_enter(pMaster);
|
||||
sqlite3GlobalConfig.isMutexInit = 1;
|
||||
if( sqlite3GlobalConfig.isInit ){
|
||||
assert( sqlite3GlobalConfig.isMutexInit );
|
||||
assert( sqlite3GlobalConfig.isMallocInit );
|
||||
sqlite3_mutex_leave(pMaster);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
sqlite3GlobalConfig.isMutexInit = 1; /* possibly redundant */
|
||||
if( !sqlite3GlobalConfig.isMallocInit ){
|
||||
rc = sqlite3MallocInit();
|
||||
}
|
||||
@@ -329,6 +335,17 @@ int sqlite3_shutdown(void){
|
||||
sqlite3GlobalConfig.isMutexInit = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Force the state of the mutex subsystem to be completely reset now, even
|
||||
** if the configured xMutexEnd(), if any, failed. This is not thread-safe.
|
||||
** This is necessary even if the xMutexInit() was never called, due to the
|
||||
** possiblity of this state being changed via SQLITE_CONFIG_MUTEX. After
|
||||
** this point, the application must enable any custom mutex implementation
|
||||
** again via SQLITE_CONFIG_MUTEX, if necessary.
|
||||
*/
|
||||
sqlite3GlobalConfig.pMutex = 0;
|
||||
memset(&sqlite3GlobalConfig.mutex, 0, sizeof(sqlite3_mutex_methods));
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -384,8 +401,15 @@ int sqlite3_config(int op, ...){
|
||||
#endif
|
||||
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */
|
||||
case SQLITE_CONFIG_MUTEX: {
|
||||
/* Specify an alternative mutex implementation */
|
||||
sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);
|
||||
/* Atomically compare-and-swap the mutex implementation pointer to
|
||||
* help prevent a race condition with sqlite3MutexInit(). */
|
||||
if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
|
||||
0, &sqlite3GlobalConfig.mutex)==0 ){
|
||||
/* Specify an alternative mutex implementation */
|
||||
sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);
|
||||
}else{
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
+60
-18
@@ -26,38 +26,80 @@ static SQLITE_WSD int mutexIsInit = 0;
|
||||
|
||||
|
||||
#ifndef SQLITE_MUTEX_OMIT
|
||||
/*
|
||||
** This structure is for use by mutexIsInvalid() only. It represents an
|
||||
** invalid mutex implementation (i.e. one where all the function pointers
|
||||
** are null).
|
||||
*/
|
||||
static const sqlite3_mutex_methods mutexNullMethods = {
|
||||
0, /* xMutexInit */
|
||||
0, /* xMutexEnd */
|
||||
0, /* xMutexAlloc */
|
||||
0, /* xMutexFree */
|
||||
0, /* xMutexEnter */
|
||||
0, /* xMutexTry */
|
||||
0, /* xMutexLeave */
|
||||
0, /* xMutexHeld */
|
||||
0 /* xMutexNotheld */
|
||||
};
|
||||
|
||||
/*
|
||||
** Returns non-zero if the currently configured mutex implemention is
|
||||
** invalid (i.e. all of its function pointers are null).
|
||||
*/
|
||||
static int mutexIsInvalid(void){
|
||||
return memcmp(&sqlite3GlobalConfig.mutex, &mutexNullMethods,
|
||||
sizeof(sqlite3_mutex_methods))==0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Copies a mutex implementation. Both arguments must point to valid
|
||||
** memory.
|
||||
*/
|
||||
static void mutexCopy(
|
||||
sqlite3_mutex_methods *pTo,
|
||||
sqlite3_mutex_methods const *pFrom
|
||||
){
|
||||
pTo->xMutexInit = pFrom->xMutexInit;
|
||||
pTo->xMutexEnd = pFrom->xMutexEnd;
|
||||
pTo->xMutexFree = pFrom->xMutexFree;
|
||||
pTo->xMutexEnter = pFrom->xMutexEnter;
|
||||
pTo->xMutexTry = pFrom->xMutexTry;
|
||||
pTo->xMutexLeave = pFrom->xMutexLeave;
|
||||
pTo->xMutexHeld = pFrom->xMutexHeld;
|
||||
pTo->xMutexNotheld = pFrom->xMutexNotheld;
|
||||
pTo->xMutexAlloc = pFrom->xMutexAlloc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize the mutex system.
|
||||
*/
|
||||
int sqlite3MutexInit(void){
|
||||
int rc = SQLITE_OK;
|
||||
if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){
|
||||
/* If the xMutexAlloc method has not been set, then the user did not
|
||||
** install a mutex implementation via sqlite3_config() prior to
|
||||
** sqlite3_initialize() being called. This block copies pointers to
|
||||
** the default implementation into the sqlite3GlobalConfig structure.
|
||||
static int initPending = 0;
|
||||
int rc;
|
||||
if( sqlite3CompareAndSwap((void * volatile *)&sqlite3GlobalConfig.pMutex,
|
||||
0, &sqlite3GlobalConfig.mutex)==0 || mutexIsInvalid() ){
|
||||
/* If the mutex implementation pointer has not been set, then the user
|
||||
** did not install a mutex implementation via sqlite3_config() prior to
|
||||
** sqlite3_initialize() being called. This block copies the pointers
|
||||
** for the default implementation into the sqlite3GlobalConfig structure.
|
||||
*/
|
||||
sqlite3_mutex_methods const *pFrom;
|
||||
sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;
|
||||
|
||||
if( sqlite3GlobalConfig.bCoreMutex ){
|
||||
pFrom = sqlite3DefaultMutex();
|
||||
}else{
|
||||
pFrom = sqlite3NoopMutex();
|
||||
}
|
||||
pTo->xMutexInit = pFrom->xMutexInit;
|
||||
pTo->xMutexEnd = pFrom->xMutexEnd;
|
||||
pTo->xMutexFree = pFrom->xMutexFree;
|
||||
pTo->xMutexEnter = pFrom->xMutexEnter;
|
||||
pTo->xMutexTry = pFrom->xMutexTry;
|
||||
pTo->xMutexLeave = pFrom->xMutexLeave;
|
||||
pTo->xMutexHeld = pFrom->xMutexHeld;
|
||||
pTo->xMutexNotheld = pFrom->xMutexNotheld;
|
||||
mutexCopy(&sqlite3GlobalConfig.mutex, pFrom);
|
||||
sqlite3MemoryBarrier();
|
||||
pTo->xMutexAlloc = pFrom->xMutexAlloc;
|
||||
}
|
||||
assert( sqlite3GlobalConfig.mutex.xMutexInit );
|
||||
rc = sqlite3GlobalConfig.mutex.xMutexInit();
|
||||
if( !initPending ){
|
||||
assert( sqlite3GlobalConfig.mutex.xMutexInit );
|
||||
initPending = 1;
|
||||
rc = sqlite3GlobalConfig.mutex.xMutexInit();
|
||||
initPending = 0;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
GLOBAL(int, mutexIsInit) = 1;
|
||||
|
||||
@@ -29,6 +29,28 @@
|
||||
|
||||
#ifndef SQLITE_MUTEX_OMIT
|
||||
|
||||
/*
|
||||
** Try to provide an atomic compare-and-swap operation on a void pointer,
|
||||
** needed for initialization only.
|
||||
*/
|
||||
void *sqlite3NoopCompareAndSwap(
|
||||
void *volatile *pCurVal,
|
||||
void *cmpVal,
|
||||
void *swapVal
|
||||
){
|
||||
/*
|
||||
** This platform may not have a way to perform an atomic compare-and-swap
|
||||
** operation; therefore, use the fallback algorithm.
|
||||
**
|
||||
** WARNING: This code is almost certainly not thread-safe.
|
||||
*/
|
||||
void *oldVal = *pCurVal;
|
||||
if( oldVal==cmpVal ){
|
||||
*pCurVal = swapVal;
|
||||
}
|
||||
return oldVal;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_DEBUG
|
||||
/*
|
||||
** Stub routines for all mutex methods.
|
||||
|
||||
@@ -91,6 +91,34 @@ void sqlite3MemoryBarrier(void){
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Try to provide an atomic compare-and-swap operation on a void pointer,
|
||||
** needed for initialization only.
|
||||
*/
|
||||
void *sqlite3CompareAndSwap(
|
||||
void *volatile *pCurVal,
|
||||
void *cmpVal,
|
||||
void *swapVal
|
||||
){
|
||||
#if defined(SQLITE_COMPARE_AND_SWAP)
|
||||
return SQLITE_COMPARE_AND_SWAP(pCurVal, cmpVal, swapVal);
|
||||
#elif defined(__GNUC__) && GCC_VERSION>=4001000 && SQLITE_PTRSIZE>4
|
||||
return (void *)__sync_val_compare_and_swap_8(
|
||||
(u64 volatile *)pCurVal, (u64)cmpVal, (u64)swapVal);
|
||||
#elif defined(__GNUC__) && GCC_VERSION>=4001000
|
||||
return (void *)__sync_val_compare_and_swap_4(
|
||||
(u32 volatile *)pCurVal, (u32)cmpVal, (u32)swapVal);
|
||||
#else
|
||||
/*
|
||||
** This platform may not have a way to perform an atomic compare-and-swap
|
||||
** operation; therefore, use the fallback algorithm.
|
||||
**
|
||||
** WARNING: This code is almost certainly not thread-safe.
|
||||
*/
|
||||
return sqlite3NoopCompareAndSwap(pCurVal, cmpVal, swapVal);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize and deinitialize the mutex subsystem.
|
||||
*/
|
||||
|
||||
@@ -90,6 +90,28 @@ void sqlite3MemoryBarrier(void){
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Try to provide an atomic compare-and-swap operation on a void pointer,
|
||||
** needed for initialization only.
|
||||
*/
|
||||
void *sqlite3CompareAndSwap(
|
||||
void * volatile *pCurVal,
|
||||
void *cmpVal,
|
||||
void *swapVal
|
||||
){
|
||||
#if defined(SQLITE_COMPARE_AND_SWAP)
|
||||
return SQLITE_COMPARE_AND_SWAP(pCurVal, cmpVal, swapVal);
|
||||
#elif SQLITE_PTRSIZE>4
|
||||
return (void *)InterlockedCompareExchange64(
|
||||
(LONGLONG SQLITE_WIN32_VOLATILE *)pCurVal, (LONGLONG)swapVal,
|
||||
(LONGLONG)cmpVal);
|
||||
#else
|
||||
return (void *)InterlockedCompareExchange(
|
||||
(LONG SQLITE_WIN32_VOLATILE *)pCurVal, (LONG)swapVal,
|
||||
(LONG)cmpVal);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize and deinitialize the mutex subsystem.
|
||||
*/
|
||||
|
||||
@@ -2938,6 +2938,7 @@ struct Sqlite3Config {
|
||||
int szLookaside; /* Default lookaside buffer size */
|
||||
int nLookaside; /* Default lookaside buffer count */
|
||||
sqlite3_mem_methods m; /* Low-level memory allocation interface */
|
||||
sqlite3_mutex_methods *pMutex; /* Address of mutex member or zero. */
|
||||
sqlite3_mutex_methods mutex; /* Low-level mutex interface */
|
||||
sqlite3_pcache_methods2 pcache2; /* Low-level page-cache interface */
|
||||
void *pHeap; /* Heap storage space */
|
||||
@@ -3189,6 +3190,7 @@ const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
|
||||
#ifndef SQLITE_MUTEX_OMIT
|
||||
sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
|
||||
sqlite3_mutex_methods const *sqlite3NoopMutex(void);
|
||||
void *sqlite3NoopCompareAndSwap(void * volatile *, void *, void *);
|
||||
sqlite3_mutex *sqlite3MutexAlloc(int);
|
||||
int sqlite3MutexInit(void);
|
||||
int sqlite3MutexEnd(void);
|
||||
@@ -3198,6 +3200,15 @@ const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
|
||||
#else
|
||||
# define sqlite3MemoryBarrier()
|
||||
#endif
|
||||
#if !defined(SQLITE_MUTEX_OMIT)
|
||||
# if !defined(SQLITE_MUTEX_NOOP)
|
||||
void *sqlite3CompareAndSwap(void * volatile *, void *, void *);
|
||||
# else
|
||||
# define sqlite3CompareAndSwap sqlite3NoopCompareAndSwap
|
||||
# endif
|
||||
#else
|
||||
# define sqlite3CompareAndSwap(x,y,z)
|
||||
#endif
|
||||
|
||||
sqlite3_int64 sqlite3StatusValue(int);
|
||||
void sqlite3StatusUp(int, int);
|
||||
|
||||
Reference in New Issue
Block a user