]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem with SQLITE_TEST_REALLOC_STRESS.
authordrh <drh@noemail.net>
Mon, 18 Jan 2016 00:20:26 +0000 (00:20 +0000)
committerdrh <drh@noemail.net>
Mon, 18 Jan 2016 00:20:26 +0000 (00:20 +0000)
FossilOrigin-Name: 0aaf3febb00f622c5ef0853b2491d69f7ca7a21e

manifest
manifest.uuid
src/pragma.c
src/sqliteInt.h
src/vdbe.h
src/vdbeaux.c

index 931cca91e8a21dcc03907544f5bfcaab07a4fa6a..1042db4582db43b892d8b3d024bc59791d5c3953 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sextra\stests\sto\scover\suntested\sbranches\sin\sfts5.
-D 2016-01-16T21:06:41.650
+C Fix\sa\sproblem\swith\sSQLITE_TEST_REALLOC_STRESS.
+D 2016-01-18T00:20:26.450
 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb
@@ -336,7 +336,7 @@ F src/parse.y caad1e98edeca6960493d0c60d31b76820dd7776
 F src/pcache.c 73895411fa6b7bd6f0091212feabbe833b358d23
 F src/pcache.h 4d0ccaad264d360981ec5e6a2b596d6e85242545
 F src/pcache1.c 72f644dc9e1468c72922eff5904048427b817051
-F src/pragma.c 53c95f5454e2a8bdb25ebf1567bed6690910ce25
+F src/pragma.c ea290193369faa0a26ae2f924e7b86289b4a7987
 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c
 F src/prepare.c 74855ddbdfad6a1c4a4d5c4b0913ebb01174ba19
 F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32
@@ -348,7 +348,7 @@ F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4
 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
-F src/sqliteInt.h 028d1f88501048b5258f7119032278a55c963512
+F src/sqliteInt.h 8fbaf9dc2bb979865c739e5272fe0b352fbc709f
 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
 F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
@@ -409,10 +409,10 @@ F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3
 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70
 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701
 F src/vdbe.c b90d9d38e5e0260c2eafa3cb4c2274d8ea94da27
-F src/vdbe.h 22f8c913bd2c8549b3d3a897da3428efbe944378
+F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337
 F src/vdbeInt.h 42eefa4f9e7432b9968d321b44e48821ec13b189
 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e
-F src/vdbeaux.c 82969fb2558e6cf57601e283f0101d0f60f5a4f2
+F src/vdbeaux.c 95e067a5e2a75e128d45ca597388dc83c58142f0
 F src/vdbeblob.c 8542f282b58293bd61c2ea4b2125f250f4fc9543
 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0
 F src/vdbesort.c 0971557e5d3c289e46f56a52aed2197c13251de7
@@ -1417,7 +1417,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 88ceb588bcdb3ca86d0c58cfdeb61b5fe070872f
-R 06f6f18fb8f74fb2b70e371e01be7b37
-U dan
-Z df25345e1d2056d2ea7917d42461493d
+P 61deab043dcea860070dba6b02601a7de627fff1
+R 4379f64b4cb45ea0db7a5f863224d3f6
+U drh
+Z e0f8e155ee8f1f04cd4cfaa23a1af003
index 539e4c0214e9d5e8e121376bbead3b3a75487942..37eeb2a0f1f59b71f57f22d659f26e7e6e0197c9 100644 (file)
@@ -1 +1 @@
-61deab043dcea860070dba6b02601a7de627fff1
\ No newline at end of file
+0aaf3febb00f622c5ef0853b2491d69f7ca7a21e
\ No newline at end of file
index 50f7229c33967ae7e08be436be703d3161116449..15f0eecce3ea2e32755a1b178a58054198cf1a42 100644 (file)
@@ -435,9 +435,9 @@ void sqlite3Pragma(
     if( !zRight ){
       setOneColumnName(v, "cache_size");
       pParse->nMem += 2;
-      sqlite3VdbeVerifyAvailableSpace(v, ArraySize(getCacheSize));
+      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize));
       aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn);
-      assert( aOp!=0 );
+      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
       aOp[0].p1 = iDb;
       aOp[1].p1 = iDb;
       aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE;
@@ -688,9 +688,9 @@ void sqlite3Pragma(
         };
         VdbeOp *aOp;
         int iAddr = sqlite3VdbeCurrentAddr(v);
-        sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setMeta6));
+        sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setMeta6));
         aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn);
-        assert( aOp!=0 );
+        if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
         aOp[0].p1 = iDb;
         aOp[1].p1 = iDb;
         aOp[2].p2 = iAddr+4;
@@ -1732,9 +1732,9 @@ void sqlite3Pragma(
         { OP_SetCookie,      0,  0,  1},    /* 2 */
       };
       VdbeOp *aOp;
-      sqlite3VdbeVerifyAvailableSpace(v, ArraySize(setCookie));
+      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie));
       aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0);
-      assert( aOp!=0 );
+      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
       aOp[0].p1 = iDb;
       aOp[1].p1 = sqlite3Atoi(zRight);
       aOp[2].p1 = iDb;
@@ -1747,9 +1747,9 @@ void sqlite3Pragma(
         { OP_ResultRow,       1,  1,  0}
       };
       VdbeOp *aOp;
-      sqlite3VdbeVerifyAvailableSpace(v, ArraySize(readCookie));
+      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie));
       aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0);
-      assert( aOp!=0 );
+      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
       aOp[0].p1 = iDb;
       aOp[1].p1 = iDb;
       aOp[1].p3 = iCookie;
index a70b0cfb36c6c9c6ce61822b9e73b30fc3484c8c..5d8a504f871705ee2a752acb50ac34f51e352569 100644 (file)
 # define NEVER(X)       (X)
 #endif
 
+/*
+** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
+** defined.  We need to defend against those failures when testing with
+** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
+** during a normal build.  The following macro can be used to disable tests
+** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
+*/
+#if defined(SQLITE_TEST_REALLOC_STRESS)
+# define ONLY_IF_REALLOC_STRESS(X)  (X)
+#elif !defined(NDEBUG)
+# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)
+#else
+# define ONLY_IF_REALLOC_STRESS(X)  (0)
+#endif
+
 /*
 ** Declarations used for tracing the operating system interfaces.
 */
index a0ff16d891da8fa617d2bc4218a53e63f7677131..f09997bf942c306bf88e8bd63df6e1aa3db40127 100644 (file)
@@ -180,10 +180,10 @@ int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
 int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
 int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
 int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
-#ifdef SQLITE_DEBUG
-  void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N);
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
+  void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
 #else
-# define sqlite3VdbeVerifyAvailableSpace(A,B)
+# define sqlite3VdbeVerifyNoMallocRequired(A,B)
 #endif
 VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
 void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
index 9859054ba4f1bd4addafa7c012f32663d014e436..492a41599be044b2cc6dedc0ab16be3a8702f733 100644 (file)
@@ -607,11 +607,14 @@ int sqlite3VdbeCurrentAddr(Vdbe *p){
 
 /*
 ** Verify that at least N opcode slots are available in p without
-** having to malloc for more space.  This interface is used for
-** testing only.
+** having to malloc for more space (except when compiled using
+** SQLITE_TEST_REALLOC_STRESS).  This interface is used during testing
+** to verify that certain calls to sqlite3VdbeAddOpList() can never
+** fail due to a OOM fault and hence that the return value from
+** sqlite3VdbeAddOpList() will always be non-NULL.
 */
-#ifdef SQLITE_DEBUG
-void sqlite3VdbeVerifyAvailableSpace(Vdbe *p, int N){
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
+void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){
   assert( p->nOp + N <= p->pParse->nOpAlloc );
 }
 #endif