/ Check-in [1109942a]
Login

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

Overview
Comment:Add a defense-in-depth NEVER() test to the WAL cleanup code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | branch-3.27
Files: files | file ages | folders
SHA3-256: 1109942a50395583ade85a725ffef7c34c594058553386d730d69ec31195cafd
User & Date: drh 2019-04-03 17:54:38
Context
2019-04-03
17:54
Add a defense-in-depth NEVER() test to the WAL cleanup code. Leaf check-in: 1109942a user: drh tags: branch-3.27
17:48
Add a defense-in-depth NEVER() test to the WAL cleanup code. check-in: 8d3af201 user: drh tags: trunk
2019-02-25
16:06
Version 3.27.2 check-in: bd49a827 user: drh tags: release, branch-3.27, version-3.27.2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

   982    982   ** actually needed.
   983    983   */
   984    984   static void walCleanupHash(Wal *pWal){
   985    985     WalHashLoc sLoc;                /* Hash table location */
   986    986     int iLimit = 0;                 /* Zero values greater than this */
   987    987     int nByte;                      /* Number of bytes to zero in aPgno[] */
   988    988     int i;                          /* Used to iterate through aHash[] */
          989  +  int rc;                         /* Return code from walHashGet() */
   989    990   
   990    991     assert( pWal->writeLock );
   991    992     testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
   992    993     testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
   993    994     testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
   994    995   
   995    996     if( pWal->hdr.mxFrame==0 ) return;
   996    997   
   997    998     /* Obtain pointers to the hash-table and page-number array containing 
   998    999     ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
   999         -  ** that the page said hash-table and array reside on is already mapped.
         1000  +  ** that the page said hash-table and array reside on is already mapped.(1)
  1000   1001     */
  1001   1002     assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
  1002   1003     assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
  1003         -  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
         1004  +  rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
         1005  +  if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
  1004   1006   
  1005   1007     /* Zero all hash-table entries that correspond to frame numbers greater
  1006   1008     ** than pWal->hdr.mxFrame.
  1007   1009     */
  1008   1010     iLimit = pWal->hdr.mxFrame - sLoc.iZero;
  1009   1011     assert( iLimit>0 );
  1010   1012     for(i=0; i<HASHTABLE_NSLOT; i++){