]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a race condition in the sorter code.
authordan <dan@noemail.net>
Mon, 5 May 2014 15:58:40 +0000 (15:58 +0000)
committerdan <dan@noemail.net>
Mon, 5 May 2014 15:58:40 +0000 (15:58 +0000)
FossilOrigin-Name: 2d2edfe58db101d42a96772b856e6e55b401aab6

manifest
manifest.uuid
src/vdbesort.c

index a8debded754138c655fe1ff9319791f73533c238..e411d8e3de847ce8ffd810ba87f51f9078e3eb74 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stests\sso\sthat\sthe\s"coverage-sorter"\stest\spermutation\scovers\sall\sbranches\sin\svdbesort.c.\sFix\sa\sfew\sminor\sproblems\sin\sthe\ssame\sfile.
-D 2014-05-05T09:08:54.007
+C Fix\sa\srace\scondition\sin\sthe\ssorter\scode.
+D 2014-05-05T15:58:40.542
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in ad0921c4b2780d01868cf69b419a4f102308d125
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -287,7 +287,7 @@ F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4
 F src/vdbeaux.c 44d4d1f5711f71eaf0d624de5c3e4976fe4e180b
 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac
 F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447
-F src/vdbesort.c af752fa4c125ab2bfeee1c4e0b50504e79aa7051
+F src/vdbesort.c b36070436d33372237541e9eaa6068e1a61bc402
 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
 F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8
@@ -1170,7 +1170,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P a33a366ba8a0da81ddd895d552a348441ef8529a
-R 48fa4af9d614a9372c1dc3ff956ba091
+P bde28b702dabd02269e333535cc41481351c5efc
+R e53afa0ba1bd427219aede77058d3d04
 U dan
-Z 1076615c7d8998a9f1b953b2c0f517bb
+Z ba1cae0a2780ce3568cf6b58bd76a820
index 8a5cb48075b4cb53cfb6e9b40eba40fec48b55cf..82ab91d82e75377fabb3e3d7aa1d0c023f6286ea 100644 (file)
@@ -1 +1 @@
-bde28b702dabd02269e333535cc41481351c5efc
\ No newline at end of file
+2d2edfe58db101d42a96772b856e6e55b401aab6
\ No newline at end of file
index 90a611914db9fdf115f97d00ff00ccdfcab50fa1..9c57135dd34e31ac864dd73c669ec7d869a41098 100644 (file)
@@ -991,7 +991,15 @@ static int vdbeSorterCreateThread(
 static int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){
   int rc = rcin;
   int i;
-  for(i=0; i<pSorter->nTask; i++){
+
+  /* This function is always called by the main user thread.
+  **
+  ** If this function is being called after SorterRewind() has been called, 
+  ** it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread
+  ** is currently attempt to join one of the other threads. To avoid a race
+  ** condition where this thread also attempts to join the same object, join 
+  ** thread pSorter->aTask[pSorter->nTask-1].pThread first. */
+  for(i=pSorter->nTask-1; i>=0; i--){
     SortSubtask *pTask = &pSorter->aTask[i];
     int rc2 = vdbeSorterJoinThread(pTask);
     if( rc==SQLITE_OK ) rc = rc2;