]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Always invoke the xRoundup() method of the memory allocator before calling
authordrh <drh@noemail.net>
Wed, 8 Feb 2017 16:01:57 +0000 (16:01 +0000)
committerdrh <drh@noemail.net>
Wed, 8 Feb 2017 16:01:57 +0000 (16:01 +0000)
xMalloc().

FossilOrigin-Name: 77b470b0df73dc5ae5ad2f0170ef7c50558c7c88

manifest
manifest.uuid
src/malloc.c
src/mem1.c

index ee914ed3f532091e970a1c147eec9bc3565b52bb..8fb5d8e602c6a157b929cc9082b6f19d2c3a2421 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Round\sup\sthe\ssize\sof\sall\smemory\sallocations\sto\sa\smultiple\sof\s8\sbytes\swhen\nusing\sthe\ssystem\smemory\sallocator.
-D 2017-02-08T12:18:05.716
+C Always\sinvoke\sthe\sxRoundup()\smethod\sof\sthe\smemory\sallocator\sbefore\scalling\nxMalloc().
+D 2017-02-08T16:01:57.242
 F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 067a6766f800cc8d72845ab61f8de4ffe8f3fc99
@@ -360,9 +360,9 @@ F src/insert.c 444354c23d4d140a57d6eb46f34e376a7f8f62e8
 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
 F src/loadext.c a68d8d1d14cf7488bb29dc5311cb1ce9a4404258
 F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0
-F src/malloc.c fc1b9f445290f2145da48fc08730c26e6082b640
+F src/malloc.c dc2b84cd320e0498ef4209772d66f353df6e4eb2
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
-F src/mem1.c d5214ba7ca6315702d4dc19c6a28c28374aabf0f
+F src/mem1.c fd7cd6fe21d46fe0a4186367dd8dc26d87b787eb
 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
 F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
@@ -1555,7 +1555,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P c8bfd99b96608a08f934f46b4e1a4d0f1cc69ea7
-R 18730fab1d81ceb35863e5f55cd414cf
+P c46e06fab4465128ac3364bafef5fa3d016796d0
+R 4a0a823e254c393eb2ca1b8aee7648b4
 U drh
-Z e4ad513632515387e7941b963a76aac0
+Z f41f90df67587790eae7117dc459eaeb
index 876796e05112ceb9fb1dfb1915832337bb051df3..e1604708ad050491bd1aa87e93a5e42ca6bfd74f 100644 (file)
@@ -1 +1 @@
-c46e06fab4465128ac3364bafef5fa3d016796d0
\ No newline at end of file
+77b470b0df73dc5ae5ad2f0170ef7c50558c7c88
\ No newline at end of file
index 0a3d891e9ba1b3cefc25a1060c80bcf972569bce..47064aafbaa55b6b0cc0d449278a93be6d990b72 100644 (file)
@@ -219,12 +219,20 @@ static void sqlite3MallocAlarm(int nByte){
 */
 static void mallocWithAlarm(int n, void **pp){
   void *p;
-  int nFull = 0;
+  int nFull;
   assert( sqlite3_mutex_held(mem0.mutex) );
+  assert( n>0 );
+
+  /* In Firefox (circa 2017-02-08), xRoundup is remapped to an internal
+  ** implementation of malloc_good_size(), which must be called in debug
+  ** mode and specifically when the DMD "Dark Matter Detector" is enabled
+  ** or else a crash results.  Hence, do not attempt to optimization out
+  ** the following xRoundup() call. */
+  nFull = sqlite3GlobalConfig.m.xRoundup(n);
+
   sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
   if( mem0.alarmThreshold>0 ){
     sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
-    nFull = sqlite3GlobalConfig.m.xRoundup(n);
     if( nUsed >= mem0.alarmThreshold - nFull ){
       mem0.nearlyFull = 1;
       sqlite3MallocAlarm(nFull);
@@ -232,11 +240,11 @@ static void mallocWithAlarm(int n, void **pp){
       mem0.nearlyFull = 0;
     }
   }
-  p = sqlite3GlobalConfig.m.xMalloc(n);
+  p = sqlite3GlobalConfig.m.xMalloc(nFull);
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   if( p==0 && mem0.alarmThreshold>0 ){
     sqlite3MallocAlarm(nFull);
-    p = sqlite3GlobalConfig.m.xMalloc(n);
+    p = sqlite3GlobalConfig.m.xMalloc(nFull);
   }
 #endif
   if( p ){
index 28055190e0947a474c55155fe0e33c2da0bfaf20..efc84c41d7658a175aca40c8b612239690987524 100644 (file)
@@ -125,7 +125,9 @@ static malloc_zone_t* _sqliteZone_;
 */
 static void *sqlite3MemMalloc(int nByte){
 #ifdef SQLITE_MALLOCSIZE
-  void *p = SQLITE_MALLOC( ROUND8(nByte) );
+  void *p;
+  testcase( ROUND8(nByte)==nByte );
+  p = SQLITE_MALLOC( nByte );
   if( p==0 ){
     testcase( sqlite3GlobalConfig.xLog!=0 );
     sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
@@ -134,7 +136,7 @@ static void *sqlite3MemMalloc(int nByte){
 #else
   sqlite3_int64 *p;
   assert( nByte>0 );
-  nByte = ROUND8(nByte);
+  testcase( ROUND8(nByte)!=nByte );
   p = SQLITE_MALLOC( nByte+8 );
   if( p ){
     p[0] = nByte;