Fix an infinite loop in the MEMSYS5 auxiliary memory allocator that occurs

for memory allocations between 1GiB and 2GiB in size.  Error introduced
by check-in [949133231f8f751a].  The problem only affects builds that
include the SQLITE_ENABLE_MEMSYS5 compile-time option.

FossilOrigin-Name: 8da0f0c38a458c57f979d59b49cf4804ef81fc2eccabde1f166bab24dd1dabea
This commit is contained in:
drh
2022-12-26 15:14:24 +00:00
parent 64fa85bb5e
commit ff78b2bee8
3 changed files with 14 additions and 10 deletions
+7 -7
View File
@@ -1,5 +1,5 @@
C Document\ssqlite3.capi.sqlite3_prepare_v3()\sas\saccepting\san\sArrayBuffer\sand\sensure\sthat\sit\scan.
D 2022-12-26T15:08:48.274
C Fix\san\sinfinite\sloop\sin\sthe\sMEMSYS5\sauxiliary\smemory\sallocator\sthat\soccurs\nfor\smemory\sallocations\sbetween\s1GiB\sand\s2GiB\sin\ssize.\s\sError\sintroduced\nby\scheck-in\s[949133231f8f751a].\s\sThe\sproblem\sonly\saffects\sbuilds\sthat\ninclude\sthe\sSQLITE_ENABLE_MEMSYS5\scompile-time\soption.
D 2022-12-26T15:14:24.028
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -614,7 +614,7 @@ F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6
F src/mem5.c 5a3dbd8ac8a6501152a4fc1fcae9b0900c2d7eb0589c4ec7456fdde15725a26c
F src/mem5.c b658f3dd447ad8963d2b4b3f0081aa71f0c827eb99f9cb54675bdf2eea5ad34e
F src/memdb.c 559c42e61eb70cd6d4bc692b042497133c6d96c09a3d514d92f3dac72268e223
F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0
F src/msvc.h 3a15918220367a8876be3fa4f2abe423a861491e84b864fb2b7426bf022a28f8
@@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P eff5d3bec29043cc1182bbb5229040dac5ff50264d025e354736bb63b4bc97a0
R 6ff80c69205054a7da640050cde0ccdf
U stephan
Z 3c914ac569efd4e323dbc54f2636bac4
P ae3ae92ec45d3d5de92e70876502f8108fc3fcd87848e86c2b83f8842f1ff139
R af6df6d036a8bd991cf092623d05af75
U drh
Z 333253e835d0b6bf644788ba3ea65af5
# Remove this line to create a well-formed Fossil manifest.
+1 -1
View File
@@ -1 +1 @@
ae3ae92ec45d3d5de92e70876502f8108fc3fcd87848e86c2b83f8842f1ff139
8da0f0c38a458c57f979d59b49cf4804ef81fc2eccabde1f166bab24dd1dabea
+6 -2
View File
@@ -424,9 +424,13 @@ static int memsys5Roundup(int n){
if( n<=mem5.szAtom ) return mem5.szAtom;
return mem5.szAtom*2;
}
if( n>0x40000000 ) return 0;
if( n>0x10000000 ){
if( n>0x40000000 ) return 0;
if( n>0x20000000 ) return 0x40000000;
return 0x2000000;
}
for(iFullSz=mem5.szAtom*8; iFullSz<n; iFullSz *= 4);
if( (iFullSz/2)>=n ) return iFullSz/2;
if( (iFullSz/2)>=(i64)n ) return iFullSz/2;
return iFullSz;
}