SQLite

Check-in [1aa5301446]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a corner case in the opcode-array reuse logic where the number of bytes of reusable space might be computed to be a negative number, due to unusual system alignment restrictions and rounding error.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1aa530144643582658c8c1dd66548662f950efe3
User & Date: drh 2016-01-04 23:43:47.141
Context
2016-01-05
01:48
Permit the 'test_fs' test module to be compiled and used on MinGW. (check-in: ac27f38eef user: mistachkin tags: trunk)
2016-01-04
23:43
Fix a corner case in the opcode-array reuse logic where the number of bytes of reusable space might be computed to be a negative number, due to unusual system alignment restrictions and rounding error. (check-in: 1aa5301446 user: drh tags: trunk)
13:06
Fix the conflict2.test module which was broken by check-in [e30062e9f6c]. (check-in: b779ca8a75 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbeaux.c.
1844
1845
1846
1847
1848
1849
1850
1851



1852
1853
1854
1855

1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
  ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1)
  ** stores the blob of memory associated with cursor 1, etc.
  **
  ** See also: allocateCursor().
  */
  nMem += nCursor;

  /* Allocate space for memory registers, SQL variables, VDBE cursors and 



  ** an array to marshal SQL function arguments in.
  */
  zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp);      /* Available space */
  nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */


  resolveP2Values(p, &nArg);
  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  if( pParse->explain && nMem<10 ){
    nMem = 10;
  }
  memset(zCsr, 0, nFree);
  assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in two
  ** passes.  On the first pass, we try to reuse unused space at the 
  ** end of the opcode array.  If we are unable to satisfy all memory
  ** requirements by reusing the opcode array tail, then the second







|
>
>
>
|



>






<







1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865

1866
1867
1868
1869
1870
1871
1872
  ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1)
  ** stores the blob of memory associated with cursor 1, etc.
  **
  ** See also: allocateCursor().
  */
  nMem += nCursor;

  /* zCsr will initially point to nFree bytes of unused space at the
  ** end of the opcode array, p->aOp.  The computation of nFree is
  ** conservative - it might be smaller than the true number of free
  ** bytes, but never larger.  nFree might be negative.  But the allocation
  ** loop will still function correctly.
  */
  zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp);      /* Available space */
  nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */
  if( nFree>0 ) memset(zCsr, 0, nFree);

  resolveP2Values(p, &nArg);
  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  if( pParse->explain && nMem<10 ){
    nMem = 10;
  }

  assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in two
  ** passes.  On the first pass, we try to reuse unused space at the 
  ** end of the opcode array.  If we are unable to satisfy all memory
  ** requirements by reusing the opcode array tail, then the second