/ Check-in [1aa53014]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1aa530144643582658c8c1dd66548662f950efe3
User & Date: drh 2016-01-04 23:43:47
Context
2016-01-05
01:48
Permit the 'test_fs' test module to be compiled and used on MinGW. check-in: ac27f38e 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: 1aa53014 user: drh tags: trunk
13:06
Fix the conflict2.test module which was broken by check-in [e30062e9f6c]. check-in: b779ca8a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  1844   1844     ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1)
  1845   1845     ** stores the blob of memory associated with cursor 1, etc.
  1846   1846     **
  1847   1847     ** See also: allocateCursor().
  1848   1848     */
  1849   1849     nMem += nCursor;
  1850   1850   
  1851         -  /* Allocate space for memory registers, SQL variables, VDBE cursors and 
  1852         -  ** an array to marshal SQL function arguments in.
         1851  +  /* zCsr will initially point to nFree bytes of unused space at the
         1852  +  ** end of the opcode array, p->aOp.  The computation of nFree is
         1853  +  ** conservative - it might be smaller than the true number of free
         1854  +  ** bytes, but never larger.  nFree might be negative.  But the allocation
         1855  +  ** loop will still function correctly.
  1853   1856     */
  1854   1857     zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp);      /* Available space */
  1855   1858     nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */
         1859  +  if( nFree>0 ) memset(zCsr, 0, nFree);
  1856   1860   
  1857   1861     resolveP2Values(p, &nArg);
  1858   1862     p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  1859   1863     if( pParse->explain && nMem<10 ){
  1860   1864       nMem = 10;
  1861   1865     }
  1862         -  memset(zCsr, 0, nFree);
  1863   1866     assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
  1864   1867     p->expired = 0;
  1865   1868   
  1866   1869     /* Memory for registers, parameters, cursor, etc, is allocated in two
  1867   1870     ** passes.  On the first pass, we try to reuse unused space at the 
  1868   1871     ** end of the opcode array.  If we are unable to satisfy all memory
  1869   1872     ** requirements by reusing the opcode array tail, then the second