-C Report\san\serror\sif\sthe\snumber\sof\snamed\scolumns\sin\sa\sVIEW\sis\sdifferent\nfrom\sthe\snumber\sof\sresult\scolumns\sin\sthe\sSELECT\sstatement\sthat\simplements\nthe\sVIEW.
-D 2015-09-25T13:42:55.978
+C Disable\sthe\sSQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS\smechanism\sand\sreplace\sit\s\nwith\sSQLITE_TESTCTRL_BENIGN_MALLOC_CTRL,\swhich\sgives\sbetter\scontrol.
+D 2015-09-25T16:29:49.729
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1afa6fb2de2bddd50e0ddae8166c2ee9d69b301
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/dbstat.c e637e7a7ff40ef32132a418c6fdf1cfb63aa27c7
F src/delete.c 371df4fc86e96efeaed3d37565aef77f956be109
F src/expr.c 3a76afcdac925294c39903b7002ddb9e5fd29863
-F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
+F src/fault.c a64e879e4713671b3b2bf1db70efa351d6ac9591
F src/fkey.c 83e1baba999bed3144ea5a2143fc922edf51135f
F src/func.c ecdd69ec6a1e406f04cc73324be2ebbf6354197f
F src/global.c 508e4087f7b41d688e4762dcf4d4fe28cfbc87f9
-F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
+F src/hash.c 5b5ce67bc4fe533f49de10b3671fcb92d4d5c4e9
F src/hash.h c8f3c31722cf3277d03713909761e152a5b81094
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c 9748a37e058256eb2ead69f028ab85ebf203ad15
F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
F src/lempar.c d344a95d60c24e2f490ee59db9784b1b17439012
F src/loadext.c f0b66d28e377fd6c6d36cc9d92df1ff251ebee44
-F src/main.c e17fcffae4306a9b8334faf3bac80d7396850b54
-F src/malloc.c 3a37ce6979a40f499d8cea9e9ab4e8517854d35d
+F src/main.c 710b2e0433a340a10c40f4dbf29838e359a44427
+F src/malloc.c 76c62c8ee6b346aa10a373229a372ef2f2344fe9
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
F src/parse.y f599aa5e871a493330d567ced93de696f61f48f7
F src/pcache.c 24be750c79272e0ca7b6e007bc94999700f3e5ef
F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9
-F src/pcache1.c e822007159d53a7ea7aa040d6e28964ddb6de083
+F src/pcache1.c 7f8630a2074997195b86f478840a603818b08d84
F src/pragma.c d71b813e67bf03f3116b9dd5164fbfd81ec673a2
F src/pragma.h 631a91c8b0e6ca8f051a1d8a4a0da4150e04620a
F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1
F src/resolve.c 1954a0f01bf65d78d7d559aea3d5c67f33376d91
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c 33230303f5f32430ee971a6fcc6a370e4a93ae1a
-F src/shell.c 6332ef06db1390ef812cfdff1fc97b4fd76cdd42
-F src/sqlite.h.in 4e06cb5fed36736242c66237991db6f3e2395eb9
+F src/shell.c 15186317f2fcb670400f8d16d298ed18731375a0
+F src/sqlite.h.in a6f2cb7741fae0133b007843b65c96f7fcd4d7fd
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 64350bf36833a56ad675e27392a913f417c5c308
-F src/sqliteInt.h 5afc6e50402be1e0a870f28e1cd8b32eb9db590f
+F src/sqliteInt.h ca695ea39aa6d459a1b1d36391c5121c432f350f
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202
F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa
F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4
-F src/test_malloc.c 27d9e11b6e9d30267465d41ad81edbe24256408b
+F src/test_malloc.c 8d0ffe32a7e46aaab2bca5cce28e69678a9a3dc5
F src/test_multiplex.c 9fefd23f6cc3fa9bf0748a5e453167e7b9f193ce
F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3
F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 1350dd42d056508337b1a07ad8b1c9c97593f8d3
-R 9672ebd00531833a09889a78098f4f34
+P 6e4ac0be2de1a16fcbb2a314504122ad95aa257e
+R e9ff57918bb5645931e56acdf4a48d22
+T *branch * malloc-testing
+T *sym-malloc-testing *
+T -sym-trunk *
U drh
-Z 160c60a319774154e17ae3a2bf9d8f26
+Z ab3c9d2f368f9a4d4d11dc236e31f593
-6e4ac0be2de1a16fcbb2a314504122ad95aa257e
\ No newline at end of file
+2c57b2f38691356405b95245fc22fd5e6bfcb2f1
\ No newline at end of file
#ifndef SQLITE_OMIT_BUILTIN_TEST
/*
-** Global variables.
+** The default xBenignCtrl function is a no-op
*/
-typedef struct BenignMallocHooks BenignMallocHooks;
-static SQLITE_WSD struct BenignMallocHooks {
- void (*xBenignBegin)(void);
- void (*xBenignEnd)(void);
-} sqlite3Hooks = { 0, 0 };
+static void sqlite3BenignCtrlNoop(int eOp){
+ (void)eOp;
+}
-/* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks
-** structure. If writable static data is unsupported on the target,
-** we have to locate the state vector at run-time. In the more common
-** case where writable static data is supported, wsdHooks can refer directly
-** to the "sqlite3Hooks" state vector declared above.
+/*
+** Global variable: Pointer to the benign malloc control interface.
*/
-#ifdef SQLITE_OMIT_WSD
-# define wsdHooksInit \
- BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)
-# define wsdHooks x[0]
-#else
-# define wsdHooksInit
-# define wsdHooks sqlite3Hooks
-#endif
-
+static void (*sqlite3xBenignCtrl)(int) = sqlite3BenignCtrlNoop;
/*
-** Register hooks to call when sqlite3BeginBenignMalloc() and
-** sqlite3EndBenignMalloc() are called, respectively.
+** Register a pointer to the benign-malloc control interface function.
+** If the argument is a NULL pointer, register the default no-op controller.
*/
-void sqlite3BenignMallocHooks(
- void (*xBenignBegin)(void),
- void (*xBenignEnd)(void)
-){
- wsdHooksInit;
- wsdHooks.xBenignBegin = xBenignBegin;
- wsdHooks.xBenignEnd = xBenignEnd;
+void sqlite3BenignMallocHooks(void (*xBenignCtrl)(int)){
+ sqlite3xBenignCtrl = xBenignCtrl ? xBenignCtrl : sqlite3BenignCtrlNoop;
}
/*
-** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that
-** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()
-** indicates that subsequent malloc failures are non-benign.
+** The sqlite3BeginBenignMalloc() and sqlite3EndBenignMalloc() calls bracket
+** sections of code for which malloc failures are non-fatal.
*/
void sqlite3BeginBenignMalloc(void){
- wsdHooksInit;
- if( wsdHooks.xBenignBegin ){
- wsdHooks.xBenignBegin();
- }
+ sqlite3xBenignCtrl(1);
}
void sqlite3EndBenignMalloc(void){
- wsdHooksInit;
- if( wsdHooks.xBenignEnd ){
- wsdHooks.xBenignEnd();
- }
+ sqlite3xBenignCtrl(0);
+}
+
+/*
+** The sqlite3PreviousBenignMalloc() call indicates that the previous
+** malloc call (which must have failed) was a benign failure.
+*/
+void sqlite3PreviousBenignMalloc(void){
+ sqlite3xBenignCtrl(2);
}
#endif /* #ifndef SQLITE_OMIT_BUILTIN_TEST */
** use the actual amount of space allocated for the hash table (which
** may be larger than the requested amount).
*/
- sqlite3BeginBenignMalloc();
new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );
- sqlite3EndBenignMalloc();
-
- if( new_ht==0 ) return 0;
+ if( new_ht==0 ){
+ sqlite3PreviousBenignMalloc();
+ return 0;
+ }
sqlite3_free(pH->ht);
pH->ht = new_ht;
pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
sz = 0;
pStart = 0;
}else if( pBuf==0 ){
- sqlite3BeginBenignMalloc();
pStart = sqlite3Malloc( sz*cnt ); /* IMP: R-61949-35727 */
- sqlite3EndBenignMalloc();
- if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;
+ if( pStart==0 ){
+ sqlite3PreviousBenignMalloc();
+ }else{
+ cnt = sqlite3MallocSize(pStart)/sz;
+ }
}else{
pStart = pBuf;
}
}
/*
- ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)
+ ** sqlite3_test_control(BENIGN_MALLOC_CTRL, xCtrl)
**
- ** Register hooks to call to indicate which malloc() failures
- ** are benign.
+ ** Register a callback function that will handle calls to
+ ** sqlite3BeginBenignMalloc(), sqlite3EndBenignMalloc(), and
+ ** sqlite3PreviousBenignMalloc(). If the callback function pointer
+ ** is NULL, then a built-in default (no-op) handler is used.
*/
- case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: {
- typedef void (*void_function)(void);
- void_function xBenignBegin;
- void_function xBenignEnd;
- xBenignBegin = va_arg(ap, void_function);
- xBenignEnd = va_arg(ap, void_function);
- sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);
+ case SQLITE_TESTCTRL_BENIGN_MALLOC_CTRL: {
+ typedef void (*void_function)(int);
+ void_function xBenignCtrl;
+ xBenignCtrl = va_arg(ap, void_function);
+ sqlite3BenignMallocHooks(xBenignCtrl);
break;
}
}
pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
if( pNew==0 && mem0.alarmThreshold>0 ){
+ sqlite3PreviousBenignMalloc();
sqlite3MallocAlarm((int)nBytes);
pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
}
if( pcache1.nInitPage==0 ) return 0;
/* Do not bother with a bulk allocation if the cache size very small */
if( pCache->nMax<3 ) return 0;
- sqlite3BeginBenignMalloc();
if( pcache1.nInitPage>0 ){
szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;
}else{
szBulk = pCache->szAlloc*pCache->nMax;
}
zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
- sqlite3EndBenignMalloc();
- if( zBulk ){
+ if( zBulk==0 ){
+ sqlite3PreviousBenignMalloc();
+ }else{
int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
int i;
for(i=0; i<nBulk; i++){
{ "prng_reset", SQLITE_TESTCTRL_PRNG_RESET },
{ "bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST },
{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL },
- { "benign_malloc_hooks", SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS },
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE },
{ "assert", SQLITE_TESTCTRL_ASSERT },
{ "always", SQLITE_TESTCTRL_ALWAYS },
}
break;
- case SQLITE_TESTCTRL_BITVEC_TEST:
- case SQLITE_TESTCTRL_FAULT_INSTALL:
- case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
- case SQLITE_TESTCTRL_SCRATCHMALLOC:
default:
fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n",
azArg[1]);
#define SQLITE_TESTCTRL_PRNG_RESET 7
#define SQLITE_TESTCTRL_BITVEC_TEST 8
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
-#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
+#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 /* NOT USED */
#define SQLITE_TESTCTRL_PENDING_BYTE 11
#define SQLITE_TESTCTRL_ASSERT 12
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
#define SQLITE_TESTCTRL_IMPOSTER 25
-#define SQLITE_TESTCTRL_LAST 25
+#define SQLITE_TESTCTRL_BENIGN_MALLOC_CTRL 26
+#define SQLITE_TESTCTRL_LAST 26
/*
** CAPI3REF: SQLite Runtime Status
void sqlite3PageFree(void*);
void sqlite3MemSetDefault(void);
#ifndef SQLITE_OMIT_BUILTIN_TEST
-void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
+void sqlite3BenignMallocHooks(void (*)(int));
#endif
int sqlite3HeapNearlyFull(void);
#ifndef SQLITE_OMIT_BUILTIN_TEST
void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void);
+ void sqlite3PreviousBenignMalloc(void);
#else
#define sqlite3BeginBenignMalloc()
#define sqlite3EndBenignMalloc()
+ #define sqlite3PreviousBenignMalloc()
#endif
/*
}
}
-
-static void faultsimBeginBenign(void){
- memfault.isBenignMode++;
-}
-static void faultsimEndBenign(void){
- memfault.isBenignMode--;
+/*
+** The SQLITE_TESTCTRL_BENIGN_MALLOC_CTRL callback. The eOp argument means:
+**
+** 0: Leave benign malloc mode
+** 1: Enter benign malloc mode (may be nested)
+** 2: Make the previous malloc failure benign if it was not already so
+*/
+static void faultsimBenignCtrl(int eOp){
+ switch( eOp ){
+ case 0: /* Leave benign malloc mode */
+ assert( memfault.isBenignMode>0 );
+ memfault.isBenignMode--;
+ break;
+ case 1: /* Enter benign malloc mode */
+ memfault.isBenignMode++;
+ break;
+ case 2: /* Previous failure is benign */
+ assert( memfault.nFail>0 );
+ if( memfault.isBenignMode==0 ) memfault.nBenign++;
+ break;
+ }
}
/*
if( rc==SQLITE_OK ){
rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &m);
}
- sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,
- faultsimBeginBenign, faultsimEndBenign
- );
+ sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_CTRL,
+ faultsimBenignCtrl);
}else{
sqlite3_mem_methods m2;
assert(memfault.m.xMalloc);
assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 );
rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m);
- sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0);
+ sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_CTRL, 0);
}
if( rc==SQLITE_OK ){