]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix some memory leak problems with corrupt.test and auto-vacuum databases. (CVS 2226)
authordanielk1977 <danielk1977@noemail.net>
Mon, 17 Jan 2005 07:53:44 +0000 (07:53 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 17 Jan 2005 07:53:44 +0000 (07:53 +0000)
FossilOrigin-Name: 6244252915fa312a6c4d192464023d95aaef4661

manifest
manifest.uuid
src/btree.c
src/build.c
src/util.c
test/all.test
test/corrupt.test
test/memleak.test
test/pager.test
test/pragma.test
tool/memleak3.tcl

index 6b101aea87d59dbe9b47a359a2aeb71e2e02130b..a03612a2c789c113ad056e34c257166f89f4ffd2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sincomplete,\spreliminary\sdrafts\sof\snew\sdocumentation.\s(CVS\s2225)
-D 2005-01-17T03:42:52
+C Fix\ssome\smemory\sleak\sproblems\swith\scorrupt.test\sand\sauto-vacuum\sdatabases.\s(CVS\s2226)
+D 2005-01-17T07:53:44
 F Makefile.in 78d6d0af3725aef32468ac9923444d7645d21a28
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -29,9 +29,9 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
 F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
 F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
-F src/btree.c da5adfeb27e7236e6e3a0a4f42de2caef0e9ad13
+F src/btree.c 97101cce85304edbaedafc5f39ab12e2dc78b076
 F src/btree.h 74d19cf40ab49fd69abe9e4e12a6c321ad86c497
-F src/build.c af1296e8a21a406b4f4c4f1e1365e075071219f3
+F src/build.c 07d50fe1b167c77f183aedd59362d55e1f579163
 F src/cursor.c f883813759742068890b1f699335872bfa8fdf41
 F src/date.c f3d1f5cd1503dabf426a198f3ebef5afbc122a7f
 F src/delete.c 32277d2834e36c7538c047f14d643751c256c73b
@@ -72,7 +72,7 @@ F src/tokenize.c c1d124ec41422c9ec14360ea3a1f98ca4acf7cf1
 F src/trigger.c 98f3b07c08ba01b34cff139ef9687883d325ae8e
 F src/update.c 0979397c41ac29c54fe0cc687a356d8629a633af
 F src/utf.c 9bece2c7b94d9002ab1bb900a7658c6f826b0f74
-F src/util.c 03ba0b0b83b14a2ddbc0aaac0681c92c8ebb0b0c
+F src/util.c 63e8d77659df88b292ac2a9dbd4766419b0ea158
 F src/vacuum.c 1a9db113a027461daaf44724c71dd1ebbd064203
 F src/vdbe.c c5a711f146415634b72b05212bab9f222b0cce26
 F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
@@ -82,7 +82,7 @@ F src/vdbeaux.c 6c294f7390880a7bb4795c9e0bc605b1a416579a
 F src/vdbemem.c 62fe89471b656a922e9879be005abf690509ead3
 F src/where.c 3a0d08505e298242f6f151f019a05129a4f8704c
 F tclinstaller.tcl 36478c3bbfc5b93ceac42d94e3c736937b808432
-F test/all.test d9c4775753de7321c0f93aac2c08b417378d509a
+F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3
 F test/alter.test 95c57a4f461fa81293e0dccef7f83889aadb169a
 F test/attach.test f39069efd4394422798f249df9a31489aa941ee1
 F test/attach2.test eeb987770f4dbe68bd29afdbc2e8cff0142e6eb5
@@ -113,7 +113,7 @@ F test/collate4.test 2d6e38e6b871073313f6d4eebfe1435c7173ebfa
 F test/collate5.test 7999fb3122386bae38acd8ccd61e0b7c5a30e289
 F test/collate6.test 6c9470d1606ee3e564675b229653e320c49ec638
 F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
-F test/corrupt.test 4b289dfd45b5987a4f12bef9693c49e42b6e76ea
+F test/corrupt.test 6a0b5215968a6afc76d975a762f912cd16d03e72
 F test/corrupt2.test cb1f813df7559de3021e01170af0bba31507a9a5
 F test/crash.test fa5d79ece85e8f6677bd81703db5f869a15963aa
 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
@@ -151,7 +151,7 @@ F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
 F test/main.test a60a1d234b5f5784097973bd395514ca56003ef1
 F test/malloc.test 4f34764cf8cfdfb0aa43face1ba933442a08eb2b
 F test/memdb.test 532aac7128a3da494cddc4461d76c6e3988f771b
-F test/memleak.test f1fa233f8295dd1d955a00d5e5ee857850f27f29
+F test/memleak.test c0af09191af44a7501ec2494fdd079ac538a256c
 F test/minmax.test e7048476940df0af11d0f2cf687572f557cd0b29
 F test/misc1.test 744f60d1025fa978708b96cb222a07a1feb1524a
 F test/misc2.test bc852f1622d98b610d1f3e2ceb36ed7271256050
@@ -160,11 +160,11 @@ F test/misc4.test 7edc2542eadd98555c2d25c222b88a93124975ae
 F test/misuse.test 600738a8e611989bc5f544303f5e311c5f228084
 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
 F test/null.test 5a945790ef21b24fd602fe2c7a23847b903f8687
-F test/pager.test 5ac7ce028a697283846d7e0c01622d253c8df1ef
+F test/pager.test f378832fd97648674feb6b452ae155b005289d41
 F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
 F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85
 F test/pagesize.test 1b826d1608fd86d2303aa895b5586052ad07eba1
-F test/pragma.test c1b4cdb2545131e4adec3250d02544688c6a5c9d
+F test/pragma.test 4a7a06bfa87fdbf2b9e5d1ab89c8af39ddae09b3
 F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57
 F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x
 F test/quick.test 91e5b8ae6663dc9e3e754b271f0384f0cae706e6
@@ -212,7 +212,7 @@ F tool/lemon.c eb3b2bbefc0d442fa459f4f1924e598e804eca9c
 F tool/lempar.c 1e61d2b6cb9d8affa264a13336bc0c088498caa4
 F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133
 F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
-F tool/memleak3.tcl 336eb50b0849dbf99b1d5462d9c37291b01b2b43
+F tool/memleak3.tcl b8eb053190e95a55dc188896afb972e8108822d6
 F tool/mkkeywordhash.c 408dccad57ed50dc67a9a1ee7fd258e0f0a07bd2
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -269,7 +269,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc
 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
 F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746
-P 1edfdcbf142b380172a26d094e6e4a3900db8463
-R 96d57a6b3f846e4dbcc0ea017de3a1a3
-U drh
-Z d0fe1f7a9cab327ab894a50df6330b34
+P a01159e8cb93199763d191b739da2a43ec88aab3
+R fbe60a34d6230243e3a7636baa8c41f3
+U danielk1977
+Z 7a02515a37f4bed08ff76d7a050b0eb0
index 4815a3d38a0a201c7f2aa094b90ce17759f37aa9..ebd74602aad39d18bfdaa01ad44705ee8da0c0d0 100644 (file)
@@ -1 +1 @@
-a01159e8cb93199763d191b739da2a43ec88aab3
\ No newline at end of file
+6244252915fa312a6c4d192464023d95aaef4661
\ No newline at end of file
index 9f3a1cc67a10534fbbe9dca67be4684188233b98..2f5a00d115b634e2c9fdceeb03179042a7bbe0c1 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.240 2005/01/17 02:12:19 danielk1977 Exp $
+** $Id: btree.c,v 1.241 2005/01/17 07:53:44 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -495,15 +495,14 @@ static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno parent){
   if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){
     TRACE(("PTRMAP_UPDATE: %d->(%d,%d)\n", key, eType, parent));
     rc = sqlite3pager_write(pPtrmap);
-    if( rc!=0 ){
-      return rc;
+    if( rc==SQLITE_OK ){
+      pPtrmap[offset] = eType;
+      put4byte(&pPtrmap[offset+1], parent);
     }
-    pPtrmap[offset] = eType;
-    put4byte(&pPtrmap[offset+1], parent);
   }
 
   sqlite3pager_unref(pPtrmap);
-  return SQLITE_OK;
+  return rc;
 }
 
 /*
index 6bfa9294927e2371af8255e46f5fdd12db2f8886..928926a4b4909d4f8d7eb1d1580e4ef20f0d8e03 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.290 2004/12/14 03:34:34 drh Exp $
+** $Id: build.c,v 1.291 2005/01/17 07:53:44 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -691,7 +691,9 @@ void sqlite3StartTable(
   ** index or table name in the same database.  Issue an error message if
   ** it does.
   */
-  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) return;
+  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
+    goto begin_table_error;
+  }
   pTable = sqlite3FindTable(db, zName, db->aDb[iDb].zName);
   if( pTable ){
     sqlite3ErrorMsg(pParse, "table %T already exists", pName);
index a9884ae6b67542b7dce47208f8ae09999b7c9730..9bde9749720bad8e36ed9d6c6fea9d1dda43cb8c 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.126 2005/01/13 02:14:25 danielk1977 Exp $
+** $Id: util.c,v 1.127 2005/01/17 07:53:44 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -27,11 +27,11 @@ void print_stack_trace(){
   int i;
   int n = backtrace(bt, 30);
 
-  sqlite3DebugPrintf("STACK: ");
+  fprintf(stderr, "STACK: ");
   for(i=0; i<n;i++){
-    sqlite3DebugPrintf("%p ", bt[i]);
+    fprintf(stderr, "%p ", bt[i]);
   }
-  sqlite3DebugPrintf("\n");
+  fprintf(stderr, "\n");
 }
 #else
 #define print_stack_trace()
index e7739222c96d66e0d8bb2e7693dc26549c067f53..2143b5ffb13fc2088845d6510a8030a46d4b1898 100644 (file)
@@ -10,7 +10,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: all.test,v 1.29 2005/01/17 01:33:14 danielk1977 Exp $
+# $Id: all.test,v 1.30 2005/01/17 07:53:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -61,9 +61,6 @@ set EXCLUDE {
 # SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
 # on tables being allocated starting at page 2).
 #
-# Also corrupt.test doesn't work, because currently SQLite can't detect
-# corruption in pointer-map pages.
-#
 ifcapable default_autovacuum {
   lappend EXCLUDE btree2.test
   lappend EXCLUDE btree4.test
@@ -89,11 +86,6 @@ for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
   if {[info exists Leak]} {
     lappend LeakList $Leak
   }
-
-  # Reset the sqlite3_temp_directory variable for the next run of tests:
-  sqlite3 db :memory:
-  db eval {PRAGMA temp_store_directory = ""}
-  db close
 }
 
 # Do one last test to look for a memory leak in the library.  This will
index 9874a50e131c14dae0676b04a821be0a8338a54c..823c4976cc88cfbed6de4f577ff2a078ea3cf3ed 100644 (file)
 # This file implements tests to make sure SQLite does not crash or
 # segfault if it sees a corrupt database file.
 #
-# $Id: corrupt.test,v 1.2 2005/01/16 23:21:00 drh Exp $
+# $Id: corrupt.test,v 1.3 2005/01/17 07:53:44 danielk1977 Exp $
+
+catch {file delete -force test.db}
+catch {file delete -force test.db-journal}
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
index abc85a0a7fe9d311a51d613d100f33f5bb3c5ac4..78552e85081168ef00ceb5c0088a6733bc5e1654 100644 (file)
@@ -10,7 +10,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: memleak.test,v 1.7 2004/09/03 18:38:46 drh Exp $
+# $Id: memleak.test,v 1.8 2005/01/17 07:53:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -41,8 +41,17 @@ set EXCLUDE {
   btree2.test
   trans.test
   crash.test
-  corrupt.test
+  autovacuum_crash.test
 }
+# Test files btree2.test and btree4.test don't work if the 
+# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend
+# on tables being allocated starting at page 2).
+#
+ifcapable default_autovacuum {
+  lappend EXCLUDE btree2.test
+  lappend EXCLUDE btree4.test
+}
+
 if {[sqlite3 -has-codec]} {
   # lappend EXCLUDE 
 }
index 26e8ee9ec9f70193105854e94847f076e38e4b69..596f363ffe1d313d1d3064fb422fbf0211446f13 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is page cache subsystem.
 #
-# $Id: pager.test,v 1.19 2005/01/13 11:07:54 danielk1977 Exp $
+# $Id: pager.test,v 1.20 2005/01/17 07:53:44 danielk1977 Exp $
 
 
 set testdir [file dirname $argv0]
@@ -411,10 +411,14 @@ do_test pager-4.6.3 {
   for {set i 1} {$i<5} {incr i} {
     set p [page_get $::p2 $i]
     page_write $p "Page $i"
+    page_unref $p
     pager_commit $::p2
   }
   pager_truncate $::p2 3
 } {}
+do_test pager-4.6.4 {
+  pager_close $::p2
+} {}
 
 do_test pager-4.99 {
   pager_close $::p1
index aba53f616f1cd84bd5c5c74ebcbf0474004b2284..4cc6e0c1d56cbc16e0482bac5f8b516b0205f7d6 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for the PRAGMA command.
 #
-# $Id: pragma.test,v 1.31 2005/01/10 02:48:49 danielk1977 Exp $
+# $Id: pragma.test,v 1.32 2005/01/17 07:53:44 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -709,6 +709,11 @@ do_test pragma-10.3 {
 
 } ;# ifcapable trigger
 
+# Reset the sqlite3_temp_directory variable for the next run of tests:
+sqlite3 dbX :memory:
+dbX eval {PRAGMA temp_store_directory = ""}
+dbX close
+
 finish_test
 
 
index 69bc4ae88edba23aa26e3f524ca353ce88fe8675..f7fa5b43b2e1b2920f74b0a5fc26edc3d62aae84 100644 (file)
@@ -13,7 +13,8 @@ exec `which tclsh` $0 "$@"
 set doco "
 This script is a tool to help track down memory leaks in the sqlite
 library. The library must be compiled with the preprocessor symbol
-SQLITE_DEBUG set to at least 2. It must be set to 3 to enable stack traces.
+SQLITE_MEMDEBUG set to at least 2. It must be set to 3 to enable stack 
+traces.
 
 To use, run the leaky application and save the standard error output.
 Then, execute this program with the first argument the name of the
@@ -47,6 +48,7 @@ proc process_input {input_file array_name} {
   set input [open $input_file]
 
   set MALLOC {([[:digit:]]+) malloc ([[:digit:]]+) bytes at 0x([[:xdigit:]]+)}
+  # set STACK {^[[:digit:]]+: STACK: (.*)$}
   set STACK {^STACK: (.*)$}
   set FREE {[[:digit:]]+ free ([[:digit:]]+) bytes at 0x([[:xdigit:]]+)}
   set REALLOC {([[:digit:]]+) realloc ([[:digit:]]+) to ([[:digit:]]+)}