From: drh <> Date: Mon, 26 Dec 2022 15:21:42 +0000 (+0000) Subject: Fix an infinite loop in the MEMSYS5 auxiliary memory allocator that occurs X-Git-Tag: version-3.40.1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=306ff5d4e860e0229728e4e228986d73fc4a99e8;p=thirdparty%2Fsqlite.git 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: c10d40ca683941be71f3be59b4251cf326a90a24e893169c744ade944dce3ee0 --- diff --git a/manifest b/manifest index 37452bbc6e..54eb8a7337 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\smemdb\svfs\sxLock()\sfunction\sallowing\sclients\sto\supgrade\sto\sEXCLUSIVE\slocks\swhen\sother\sconnections\sare\sholding\sSHARED. -D 2022-12-05T14:23:06.852 +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:21:42.738 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -606,7 +606,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 281e5cea3368b6ada342da37c4cffa88060cb4ee803caf9d83f2422a5ced512d F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0 F src/msvc.h 3a15918220367a8876be3fa4f2abe423a861491e84b864fb2b7426bf022a28f8 @@ -2055,9 +2055,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e2ae2ea195593f142e4a0c23b7d18381efcaa4114b1de04a97543ac264cd527e -Q +15f0be8a640e7bfa4130edd4650a745337bd96083b119a1553f9abf9ff066806 -R d07b70ffc1cbebb6ce31a34bad8efad2 +P d18cce37b5b73bb2a4f28eb1b55eb2c3ffe1fc23c921c13170af3d74a549f48e +Q +8da0f0c38a458c57f979d59b49cf4804ef81fc2eccabde1f166bab24dd1dabea +R 2c5b08ba1e22dd61038e8865cc6e3975 U drh -Z 5db10dbe2408f5c4d9fdadd54b894daf +Z f8e2b7b61dcdda51d9c96216eeaf6f7d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2e6a001cc3..045fb949b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d18cce37b5b73bb2a4f28eb1b55eb2c3ffe1fc23c921c13170af3d74a549f48e \ No newline at end of file +c10d40ca683941be71f3be59b4251cf326a90a24e893169c744ade944dce3ee0 \ No newline at end of file diff --git a/src/mem5.c b/src/mem5.c index b61b93e112..336f893c6a 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -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 ) return iFullSz/2; + if( (iFullSz/2)>=(i64)n ) return iFullSz/2; return iFullSz; }