From: danielk1977 Date: Fri, 20 Mar 2009 14:18:51 +0000 (+0000) Subject: Make sure struct WhereClause is aligned on an 8-byte boundary. Fix for #3613, #3736... X-Git-Tag: version-3.6.15~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be2296501c03e6807408c3a5c4b062a24daca561;p=thirdparty%2Fsqlite.git Make sure struct WhereClause is aligned on an 8-byte boundary. Fix for #3613, #3736. (CVS 6364) FossilOrigin-Name: 093a0cf4adc8613f744c2ccdef61f0b30a46818c --- diff --git a/manifest b/manifest index ecfcd0c706..7887ffb455 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\sthe\sunused\sMEM2\sstatic\smutex\sto\sOPEN\sand\sreuse\sit\sto\sserialize\saccess\nto\sthe\ssqlite3BtreeOpen()\sroutine\sto\sprevent\sa\srace\scondition\son\sdetection\nof\ssharable\scaches.\s\sTicket\s#3735.\s(CVS\s6363) -D 2009-03-20T13:15:30 +C Make\ssure\sstruct\sWhereClause\sis\saligned\son\san\s8-byte\sboundary.\sFix\sfor\s#3613,\s#3736.\s(CVS\s6364) +D 2009-03-20T14:18:52 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -105,7 +105,7 @@ F src/bitvec.c 44f7059ac1f874d364b34af31b9617e52223ba75 F src/btmutex.c 341502bc496dc0840dcb00cde65680fb0e85c3ab F src/btree.c 4fbb5f26f450bee7356ec63cb664c8d733e28d89 F src/btree.h e302c5747494067cd4f5763000fbe7bca767d816 -F src/btreeInt.h 17697718bb5281b12da5c65ecb0bffc45f2c0125 +F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5 F src/build.c c816377c118047418fda81edb8866b9c7a4e4031 F src/callback.c 09c6fedc77a45db99ba25a75d61382830314b357 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c @@ -159,7 +159,7 @@ F src/select.c 4d0b77fd76ff80f09a798ee98953e344c9de8fbb F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7 F src/sqlite.h.in 0db1e59d89aeacb8fe64a19fd14c13a796060ccb F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 -F src/sqliteInt.h 250be86c98646e0d48436d6455b6fe916742bffa +F src/sqliteInt.h 0ba7aac31f707d69f73455f2cff296787f76e109 F src/sqliteLimit.h ffe93f5a0c4e7bd13e70cd7bf84cfb5c3465f45d F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/table.c 332ab0ea691e63862e2a8bdfe2c0617ee61062a3 @@ -209,7 +209,7 @@ F src/vdbeblob.c 3408f5e1ab62627300b9c9c3168cff1de65e1658 F src/vdbemem.c 543a79d722734d2f8b7ad70f08218c30bcc5bbf5 F src/vtab.c 18d671f0a45d0159088070bc6b219a3105034c87 F src/walker.c 42bd3f00ca2ef5ae842304ec0d59903ef051412d -F src/where.c ac555c8f6ef71a80944b31dcb212f7127c9ae30c +F src/where.c 42d3756dbed6ed390bafcd849cc2075230e0eda6 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -709,7 +709,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 56e6fca1a9da69c3a0fe43b00db9a6d9d93f03ba -R e2b2822c930e07999a7faadbecce8455 -U drh -Z 94771809e81ff193bb7785b130c75e1e +P 19fa5a29b97f017a9e176e48c848100299ba6920 +R 7488665d9a2cafa9025a5fd3b2a16baf +U danielk1977 +Z 7d097ac4987cc470b6a73e382cea7d80 diff --git a/manifest.uuid b/manifest.uuid index 5d0835618f..770f993086 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19fa5a29b97f017a9e176e48c848100299ba6920 \ No newline at end of file +093a0cf4adc8613f744c2ccdef61f0b30a46818c \ No newline at end of file diff --git a/src/btreeInt.h b/src/btreeInt.h index 3d2d02c9ea..0c196d36e6 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btreeInt.h,v 1.45 2009/03/18 10:33:01 danielk1977 Exp $ +** $Id: btreeInt.h,v 1.46 2009/03/20 14:18:52 danielk1977 Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -205,11 +205,6 @@ */ #include "sqliteInt.h" -/* Round up a number to the next larger multiple of 8. This is used -** to force 8-byte alignment on 64-bit architectures. -*/ -#define ROUND8(x) ((x+7)&~7) - /* The following value is the maximum cell size assuming a maximum page ** size give above. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f2833180da..506daaee94 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.843 2009/03/18 10:33:01 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.844 2009/03/20 14:18:52 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -444,6 +444,12 @@ extern const int sqlite3one; #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) +/* +** Round up a number to the next larger multiple of 8. This is used +** to force 8-byte alignment on 64-bit architectures. +*/ +#define ROUND8(x) ((x+7)&~7) + /* ** An instance of the following structure is used to store the busy-handler ** callback for a given sqlite handle. diff --git a/src/where.c b/src/where.c index c506339f78..96e4652451 100644 --- a/src/where.c +++ b/src/where.c @@ -16,7 +16,7 @@ ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.374 2009/03/05 03:48:07 shane Exp $ +** $Id: where.c,v 1.375 2009/03/20 14:18:52 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -2861,7 +2861,7 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ assert( pInfo->needToFreeIdxStr==0 || db->mallocFailed ); if( pInfo->needToFreeIdxStr ){ sqlite3_free(pInfo->idxStr); - } + } sqlite3DbFree(db, pInfo); } } @@ -2968,6 +2968,7 @@ WhereInfo *sqlite3WhereBegin( int regRowSet /* Register hold RowSet if WHERE_FILL_ROWSET is set */ ){ int i; /* Loop counter */ + int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ WhereInfo *pWInfo; /* Will become the return value of this function */ Vdbe *v = pParse->pVdbe; /* The virtual database engine */ Bitmask notReady; /* Cursors that are not yet positioned */ @@ -2993,15 +2994,19 @@ WhereInfo *sqlite3WhereBegin( } /* Allocate and initialize the WhereInfo structure that will become the - ** return value. + ** return value. A single allocation is used to store the WhereInfo + ** struct, the contents of WhereInfo.a[], the WhereClause structure + ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte + ** field (type Bitmask) it must be aligned on an 8-byte boundary on + ** some architectures. Hence the ROUND8() below. */ db = pParse->db; - pWInfo = sqlite3DbMallocZero(db, - sizeof(WhereInfo) - + (pTabList->nSrc-1)*sizeof(WhereLevel) - + sizeof(WhereClause) - + sizeof(WhereMaskSet) - ); + nByteWInfo = ROUND8(sizeof(WhereInfo)+(pTabList->nSrc-1)*sizeof(WhereLevel)); + pWInfo = sqlite3DbMallocZero(db, + nByteWInfo + + sizeof(WhereClause) + + sizeof(WhereMaskSet) + ); if( db->mallocFailed ){ goto whereBeginError; } @@ -3010,7 +3015,7 @@ WhereInfo *sqlite3WhereBegin( pWInfo->pTabList = pTabList; pWInfo->iBreak = sqlite3VdbeMakeLabel(v); pWInfo->regRowSet = (wctrlFlags & WHERE_FILL_ROWSET) ? regRowSet : -1; - pWInfo->pWC = pWC = (WhereClause*)&pWInfo->a[pWInfo->nLevel]; + pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo]; pWInfo->wctrlFlags = wctrlFlags; pMaskSet = (WhereMaskSet*)&pWC[1];