]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Trying to open a transaction in one thread and close it in another is a misuse with...
authordan <dan@noemail.net>
Wed, 9 Sep 2009 18:46:52 +0000 (18:46 +0000)
committerdan <dan@noemail.net>
Wed, 9 Sep 2009 18:46:52 +0000 (18:46 +0000)
FossilOrigin-Name: ef99eb57c536d82e7c19fd3d990c17793cc64a3f

manifest
manifest.uuid
src/os_unix.c
src/test4.c
test/thread2.test

index 282c146527c5da504ae6e4331ce2a7289056291d..1b1daa0c822030793018d2a119c86a9247526233 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Suppress\ssome\sharmless\scompiler\swarnings.
-D 2009-09-09T16:10:51
+C Trying\sto\sopen\sa\stransaction\sin\sone\sthread\sand\sclose\sit\sin\sanother\sis\sa\smisuse\swith\sLinuxThreads.\sDoing\sso\smay\scause\smemory\sand\sfile-descriptors\sto\sbe\sleaked.\sUpdate\san\sassert()\sand\ssome\stest\scases\sto\saccount\sfor\sthis.
+D 2009-09-09T18:46:53
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -148,7 +145,7 @@ F src/os.c 8d62d8d98ad7909cb0dd294c1e5f3835c887ccb6
 F src/os.h 00a1334a4eecee7f7bef79ac606b88d325119f21
 F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
-F src/os_unix.c 0b94e58153de8e4c1de92d66f2d1bb006a36b749
+F src/os_unix.c 4e5ce6099b6f9f711aced9283838f6a675194cc4
 F src/os_win.c 58bb163f327e79726dd119344d908e4d98483c3f
 F src/pager.c ebd0a8f2421e8f0ad5b78201440004bf3e1c96d8
 F src/pager.h 11852d044c86cf5a9d6e34171fb0c4fcf1f6265f
@@ -174,7 +171,7 @@ F src/tclsqlite.c 5eea5025c370d3a91ce0415f9d46f96fdc7aef44
 F src/test1.c 83a685fa2c96f005934ed09146b53522b1aa533e
 F src/test2.c 0de743ec8890ca4f09e0bce5d6d5a681f5957fec
 F src/test3.c 2445c2beb5e7a0c91fd8136dc1339ec369a24898
-F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
+F src/test4.c b5fd530f02a6a0dbffb23be202168a690985dedd
 F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
 F src/test6.c 1a0a7a1f179469044b065b4a88aab9faee114101
 F src/test7.c b94e68c2236de76889d82b8d7d8e00ad6a4d80b1
@@ -580,7 +577,7 @@ F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca
 F test/thread004.test f51dfc3936184aaf73ee85f315224baad272a87f
 F test/thread005.test bf5c374ca65dd89fd56c8fe511ccfb46875bda5e
 F test/thread1.test 862dd006d189e8b0946935db17399dcac2f8ef91
-F test/thread2.test 91f105374f18a66e73a3254c28fe7c77af69bdea
+F test/thread2.test 6e0997f7beabb6a7e471bd18740ed04805c785f4
 F test/thread_common.tcl b65e6b1d1d90dc885e10ad080896c6c56eef0819
 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
 F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
@@ -753,14 +750,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P f3a0f23bc77f8c73924f1d371afae9a0f65bae67
-R b16c1b731cdc4658184133bff960f4e9
-U drh
-Z 9364e9d4ce92a22f7d14a7b57436a994
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFKp9OPoxKgR168RlERAi6/AJ9Ts3lTzWavfx23Xorcbo4eQkzl9wCeJxVU
-IgsZnwseNwvtNHambzFTAso=
-=57r7
------END PGP SIGNATURE-----
+P f0c72a53c5d57d7487b48a06a40816153f47aaac
+R d486036c6384ca6df6f85368b01b5fb2
+U dan
+Z 4b9f16e8e4998457495bb5a33267dcee
index f25000b5a803f529d64e3a628a27121bc414eb3a..0e4c59d99ee93daf3c19f5b059521a517dc0e5d7 100644 (file)
@@ -1 +1 @@
-f0c72a53c5d57d7487b48a06a40816153f47aaac
\ No newline at end of file
+ef99eb57c536d82e7c19fd3d990c17793cc64a3f
\ No newline at end of file
index 9b6afe5371422d4cd8658f72f3f960d888708c70..a45aaa1d73be2953534e531bbe3fe0d586364c02 100644 (file)
@@ -925,7 +925,15 @@ static void releaseOpenCnt(struct unixOpenCnt *pOpen){
         assert( pOpen->pNext->pPrev==pOpen );
         pOpen->pNext->pPrev = pOpen->pPrev;
       }
-      assert( !pOpen->pUnused );
+      assert( !pOpen->pUnused || threadsOverrideEachOthersLocks==0 );
+
+      /* If pOpen->pUnused is not null, then memory and file-descriptors
+      ** are leaked.
+      **
+      ** This will only happen if, under Linuxthreads, the user has opened
+      ** a transaction in one thread, then attempts to close the database
+      ** handle from another thread (without first unlocking the db file).
+      ** This is a misuse.  */
       sqlite3_free(pOpen);
     }
   }
index c51d2a64057148f6c03c04512290a4633d5341a3..654b572dbf7e220fcc2ff30be4f596e696f4cc06 100644 (file)
@@ -650,6 +650,36 @@ static int tcl_thread_db_get(
   return TCL_OK;
 }
 
+/*
+** Usage: thread_db_put ID DB
+**
+*/
+static int tcl_thread_db_put(
+  void *NotUsed,
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int argc,              /* Number of arguments */
+  const char **argv      /* Text of each argument */
+){
+  int i;
+  extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);
+  extern void *sqlite3TestTextToPtr(const char *);
+  if( argc!=3 ){
+    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+       " ID DB", 0);
+    return TCL_ERROR;
+  }
+  i = parse_thread_id(interp, argv[1]);
+  if( i<0 ) return TCL_ERROR;
+  if( !threadset[i].busy ){
+    Tcl_AppendResult(interp, "no such thread", 0);
+    return TCL_ERROR;
+  }
+  thread_wait(&threadset[i]);
+  assert( !threadset[i].db );
+  threadset[i].db = (sqlite3*)sqlite3TestTextToPtr(argv[2]);
+  return TCL_OK;
+}
+
 /*
 ** Usage: thread_stmt_get ID
 **
@@ -704,6 +734,7 @@ int Sqlitetest4_Init(Tcl_Interp *interp){
      { "thread_finalize",   (Tcl_CmdProc*)tcl_thread_finalize   },
      { "thread_swap",       (Tcl_CmdProc*)tcl_thread_swap       },
      { "thread_db_get",     (Tcl_CmdProc*)tcl_thread_db_get     },
+     { "thread_db_put",     (Tcl_CmdProc*)tcl_thread_db_put     },
      { "thread_stmt_get",   (Tcl_CmdProc*)tcl_thread_stmt_get   },
   };
   int i;
index 9547accb55700bcb48737655e8e6c4cf8af7c3d4..2ec75a24cd19d0fd0a9e3f67641bf3e0174b5713 100644 (file)
@@ -192,9 +192,6 @@ do_test thread2-3.20 {
   thread_step A
   set STMT [thread_stmt_get A]
   set DB [thread_db_get A]
-  thread_halt A
-} {}
-do_test thread2-3.21 {
   sqlite3_step $STMT
 } SQLITE_ROW
 do_test thread2-3.22 {
@@ -204,11 +201,13 @@ do_test thread2-3.23 {
   # The unlock fails here.  But because we never check the return
   # code from sqlite3OsUnlock (because we cannot do anything about it
   # if it fails) we do not realize that an error has occurred.
+  breakpoint
   sqlite3_finalize $STMT
 } SQLITE_OK
 do_test thread2-3.25 {
-  sqlite3_close $DB
-} SQLITE_OK
+  thread_db_put A $DB
+  thread_halt A
+} {}
 
 do_test thread2-3.30 {
   thread_create A test.db
@@ -219,9 +218,6 @@ do_test thread2-3.30 {
   thread_step A
   thread_finalize A
   set DB [thread_db_get A]
-  thread_halt A
-} {}
-do_test thread2-3.31 {
   set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(99,'error')} -1 TAIL]
   sqlite3_step $STMT
 } SQLITE_ERROR
@@ -229,8 +225,9 @@ do_test thread2-3.32 {
   sqlite3_finalize $STMT
 } SQLITE_MISUSE
 do_test thread2-3.33 {
-  sqlite3_close $DB
-} SQLITE_OK
+  thread_db_put A $DB
+  thread_halt A
+} {}
 
 # VERY important to set the override flag back to its true value.
 #