------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Omit\sunnecessary\sOP_Next\sand\sOP_Prev\soperators\swhen\suniqueness\sconstraints\nguarantee\sthat\sthe\scode\swill\sonly\smake\sone\spass\sthrough\sthe\sloop.
-D 2011-03-09T21:02:31.691
+C Fix\sissue\swith\smem5\sallocator\swhen\smin\srequest\ssize\sis\slarger\sthatn\s2^30.
+D 2011-03-09T21:36:17.288
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e
-F src/main.c 93d0d967d6898fc0408ece248342342e312aa753
+F src/main.c b43dc11c8335ceb759d48358ddafe09f02b18a1d
F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf
F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3
-F src/mem5.c 6fe00f46997bebb690397cb029719f711e7640e3
+F src/mem5.c ebc2530757a9b0f44b61a899aef0109effd55ce8
F src/memjournal.c 0ebce851677a7ac035ba1512a7e65851b34530c6
F src/mutex.c 6949180803ff05a7d0e2b9334a95b4fb5a00e23f
F src/mutex.h fe2ef5e1c4dae531d5a544f9241f19c56d26803d
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c d24406c45dd2442eb2eeaac413439066b149c944
F src/shell.c 649c51979812f77f97507024a4cea480c6862b8b
-F src/sqlite.h.in 82274d7f4440b99a80d8cc4f077547fd0b596017
+F src/sqlite.h.in 369c767e6b9f101d63d8e4c5e40279f975ccec08
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
F src/sqliteInt.h 2cea3e47997e3f4d9b4f1ce62f99c35be1b5a586
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9
F test/malloc_common.tcl 660b82ab528521cc4a48ff6df05ca3b6a00d47c5
F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c
+F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test 0825155b2290e900264daaaf0334b6dfe69ea498
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/memsubsys1.test 679db68394a5692791737b150852173b3e2fea10
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P dc46156a2237701679433779b871844f4f2abe4b
-R 6a96206125f553ae6e4986479b4fa19e
-U drh
-Z 3c4f85bbdfea18f22f89d0b2d92c8936
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFNd+rroxKgR168RlERAk+tAJ9jEIHTwnjObklOR5pMe4sV08k4IgCeI8br
-wFEqDe541wz3+xTQUIuHIUY=
-=D87j
------END PGP SIGNATURE-----
+P f000c9b2b7348238fe2085140d2dd05294a19709
+R 5c4a42c07b3ab928630b72159bbdf550
+U shaneh
+Z 82918d77f73b87eb8c0dd11fedd7903d
-f000c9b2b7348238fe2085140d2dd05294a19709
\ No newline at end of file
+d7dae06fb2d57ed6b9555b774712f42077ae4155
\ No newline at end of file
sqlite3GlobalConfig.nHeap = va_arg(ap, int);
sqlite3GlobalConfig.mnReq = va_arg(ap, int);
+ if( sqlite3GlobalConfig.mnReq<1 ){
+ sqlite3GlobalConfig.mnReq = 1;
+ }else if( sqlite3GlobalConfig.mnReq>(1<<12) ){
+ /* cap min request size at 2^12 */
+ sqlite3GlobalConfig.mnReq = (1<<12);
+ }
+
if( sqlite3GlobalConfig.pHeap==0 ){
/* If the heap pointer is NULL, then restore the malloc implementation
** back to NULL pointers too. This will cause the malloc to go
*/
static int memsys5Log(int iValue){
int iLog;
- for(iLog=0; (1<<iLog)<iValue; iLog++);
+ for(iLog=0; (iLog<((sizeof(int)*8)-2)) && (1<<iLog)<iValue; iLog++);
return iLog;
}
zByte = (u8*)sqlite3GlobalConfig.pHeap;
assert( zByte!=0 ); /* sqlite3_config() does not allow otherwise */
- nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);
+ /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */
+ nMinLog = sqlite3GlobalConfig.mnReq;
+ assert( nMinLog>0 && nMinLog<=(1<<12) );
+ nMinLog = memsys5Log(nMinLog);
mem5.szAtom = (1<<nMinLog);
while( (int)sizeof(Mem5Link)>mem5.szAtom ){
mem5.szAtom = mem5.szAtom << 1;
** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
** allocator is engaged to handle all of SQLites memory allocation needs.
** The first pointer (the memory pointer) must be aligned to an 8-byte
-** boundary or subsequent behavior of SQLite will be undefined.</dd>
+** boundary or subsequent behavior of SQLite will be undefined.
+** The minimum allocation size is capped at 2^12. Reasonable values
+** for the minimum allocation size are 2^5 through 2^8.</dd>
**
** <dt>SQLITE_CONFIG_MUTEX</dt>
** <dd> ^(This option takes a single argument which is a pointer to an
--- /dev/null
+# 2011 March 9
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests of the mem5 allocation subsystem.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !mem5 {
+ finish_test
+ return
+}
+
+# The tests in this file configure the lookaside allocator after a
+# connection is opened. This will not work if there is any "presql"
+# configured (SQL run within the [sqlite3] wrapper in tester.tcl).
+if {[info exists ::G(perm:presql)]} {
+ finish_test
+ return
+}
+
+do_test mem5-1.1 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 25000000 0
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+# try with min request size = 2^30
+do_test mem5-1.2 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 1 1073741824
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_NOMEM}
+
+# try with min request size = 2^30+1
+# previously this was causing the memsys5Log() func to infinitely loop.
+do_test mem5-1.3 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 1 1073741825
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_NOMEM}
+
+do_test mem5-1.4 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config_heap 0 0
+ sqlite3_config_lookaside 0 0
+ sqlite3_initialize
+} {SQLITE_OK}
+
+finish_test