/ Check-in [f4a701d5]
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:Modifications to test files to omit any tests that intentionally access out-of-bounds locations in clang -fsanitize=address builds.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f4a701d55f5c4e1e62ed64b779ad4fff89dd31b7
User & Date: dan 2014-01-23 14:44:08
Context
2014-01-24
11:16
Add test cases showing the use of ORDER BY on a recursive query to control depth-first versus breath-first search of a tree. check-in: 83b0b291 user: drh tags: trunk
2014-01-23
14:44
Modifications to test files to omit any tests that intentionally access out-of-bounds locations in clang -fsanitize=address builds. check-in: f4a701d5 user: dan tags: trunk
2014-01-22
19:23
Avoid an extra seek when inserting records into the epheremal index used to ensure that rows returned by UNION recursive queries are unique. check-in: 72c4b3f0 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test1.c.

   238    238       }
   239    239       sqlite3IoTrace = io_trace_callback;
   240    240     }
   241    241   #endif
   242    242     return TCL_OK;
   243    243   }
   244    244   
   245         -
          245  +/*
          246  +** Usage:  clang_sanitize_address 
          247  +**
          248  +** Returns true if the program was compiled using clang with the 
          249  +** -fsanitize=address switch on the command line. False otherwise.
          250  +*/
          251  +static int clang_sanitize_address(
          252  +  void *NotUsed,
          253  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
          254  +  int argc,              /* Number of arguments */
          255  +  char **argv            /* Text of each argument */
          256  +){
          257  +  int res = 0;
          258  +#if defined(__has_feature)
          259  +# if __has_feature(address_sanitizer)
          260  +  res = 1;
          261  +# endif
          262  +#endif
          263  +  Tcl_SetObjResult(interp, Tcl_NewIntObj(res));
          264  +  return TCL_OK;
          265  +}
          266  +  
   246    267   /*
   247    268   ** Usage:  sqlite3_exec_printf  DB  FORMAT  STRING
   248    269   **
   249    270   ** Invoke the sqlite3_exec_printf() interface using the open database
   250    271   ** DB.  The SQL is the string FORMAT.  The format string should contain
   251    272   ** one %s or %q.  STRING is the value inserted into %s or %q.
   252    273   */
................................................................................
  6319   6340        { "sqlite_delete_function",        (Tcl_CmdProc*)delete_function       },
  6320   6341        { "sqlite_delete_collation",       (Tcl_CmdProc*)delete_collation      },
  6321   6342        { "sqlite3_get_autocommit",        (Tcl_CmdProc*)get_autocommit        },
  6322   6343        { "sqlite3_stack_used",            (Tcl_CmdProc*)test_stack_used       },
  6323   6344        { "sqlite3_busy_timeout",          (Tcl_CmdProc*)test_busy_timeout     },
  6324   6345        { "printf",                        (Tcl_CmdProc*)test_printf           },
  6325   6346        { "sqlite3IoTrace",              (Tcl_CmdProc*)test_io_trace         },
         6347  +     { "clang_sanitize_address",        (Tcl_CmdProc*)clang_sanitize_address },
  6326   6348     };
  6327   6349     static struct {
  6328   6350        char *zName;
  6329   6351        Tcl_ObjCmdProc *xProc;
  6330   6352        void *clientData;
  6331   6353     } aObjCmd[] = {
  6332   6354        { "sqlite3_connection_pointer",    get_sqlite_pointer, 0 },

Changes to test/capi3.test.

   175    175   } {SQLITE_CANTOPEN}
   176    176   do_test capi3-3.4 {
   177    177     sqlite3_errmsg $db2
   178    178   } {unable to open database file}
   179    179   do_test capi3-3.5 {
   180    180     sqlite3_close $db2
   181    181   } {SQLITE_OK}
   182         -do_test capi3-3.6.1-misuse {
   183         -  sqlite3_close $db2
   184         -} {SQLITE_MISUSE}
   185         -do_test capi3-3.6.2-misuse {
   186         -  sqlite3_errmsg $db2
   187         -} {library routine called out of sequence}
   188         -ifcapable {utf16} {
   189         -  do_test capi3-3.6.3-misuse {
   190         -    utf8 [sqlite3_errmsg16 $db2]
          182  +if {[clang_sanitize_address]==0} {
          183  +  do_test capi3-3.6.1-misuse {
          184  +    sqlite3_close $db2
          185  +  } {SQLITE_MISUSE}
          186  +  do_test capi3-3.6.2-misuse {
          187  +    sqlite3_errmsg $db2
   191    188     } {library routine called out of sequence}
          189  +  ifcapable {utf16} {
          190  +    do_test capi3-3.6.3-misuse {
          191  +      utf8 [sqlite3_errmsg16 $db2]
          192  +    } {library routine called out of sequence}
          193  +  }
   192    194   }
   193    195   
   194    196   do_test capi3-3.7 {
   195    197     set db2 [sqlite3_open]
   196    198     sqlite3_errcode $db2
   197    199   } {SQLITE_OK}
   198    200   do_test capi3-3.8 {
................................................................................
   657    659     sqlite3_step $STMT
   658    660   } {SQLITE_ROW}
   659    661   #check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
   660    662   do_test capi3-6.3 {
   661    663     sqlite3_finalize $STMT
   662    664   } {SQLITE_OK}
   663    665   
   664         -do_test capi3-6.4-misuse {
   665         -  db cache flush
   666         -  sqlite3_close $DB
   667         -} {SQLITE_OK}
          666  +if {[clang_sanitize_address]==0} {
          667  +  do_test capi3-6.4-misuse {
          668  +    db cache flush
          669  +    sqlite3_close $DB
          670  +  } {SQLITE_OK}
          671  +}
   668    672   db close
   669    673   
   670    674   # This procedure sets the value of the file-format in file 'test.db'
   671    675   # to $newval. Also, the schema cookie is incremented.
   672    676   # 
   673    677   proc set_file_format {newval} {
   674    678     hexio_write test.db 44 [hexio_render_int32 $newval]
................................................................................
  1056   1060     do_test capi3-13-5 {
  1057   1061       set ms [sqlite3_sleep 80]
  1058   1062       expr {$ms==80 || $ms==1000}
  1059   1063     } {1}
  1060   1064   }
  1061   1065   
  1062   1066   # Ticket #1219:  Make sure binding APIs can handle a NULL pointer.
  1063         -#
  1064         -do_test capi3-14.1-misuse {
  1065         -  set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
  1066         -  lappend rc $msg
  1067         -} {1 SQLITE_MISUSE}
         1067  +# 
         1068  +if {[clang_sanitize_address]==0} {
         1069  +  do_test capi3-14.1-misuse {
         1070  +    set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
         1071  +      lappend rc $msg
         1072  +  } {1 SQLITE_MISUSE}
         1073  +}
  1068   1074   
  1069   1075   # Ticket #1650:  Honor the nBytes parameter to sqlite3_prepare.
  1070   1076   #
  1071   1077   do_test capi3-15.1 {
  1072   1078     set sql {SELECT * FROM t2}
  1073   1079     set nbytes [string length $sql]
  1074   1080     append sql { WHERE a==1}

Changes to test/capi3c.test.

   165    165   } {SQLITE_CANTOPEN}
   166    166   do_test capi3c-3.4 {
   167    167     sqlite3_errmsg $db2
   168    168   } {unable to open database file}
   169    169   do_test capi3c-3.5 {
   170    170     sqlite3_close $db2
   171    171   } {SQLITE_OK}
   172         -do_test capi3c-3.6.1-misuse {
   173         -  sqlite3_close $db2
   174         -} {SQLITE_MISUSE}
   175         -do_test capi3c-3.6.2-misuse {
   176         -  sqlite3_errmsg $db2
   177         -} {library routine called out of sequence}
   178         -ifcapable {utf16} {
   179         -  do_test capi3c-3.6.3-misuse {
   180         -    utf8 [sqlite3_errmsg16 $db2]
          172  +if {[clang_sanitize_address]==0} {
          173  +  do_test capi3c-3.6.1-misuse {
          174  +    sqlite3_close $db2
          175  +  } {SQLITE_MISUSE}
          176  +  do_test capi3c-3.6.2-misuse {
          177  +    sqlite3_errmsg $db2
   181    178     } {library routine called out of sequence}
          179  +  ifcapable {utf16} {
          180  +    do_test capi3c-3.6.3-misuse {
          181  +      utf8 [sqlite3_errmsg16 $db2]
          182  +    } {library routine called out of sequence}
          183  +  }
   182    184   }
   183    185   
   184    186   # rename sqlite3_open ""
   185    187   # rename sqlite3_open_old sqlite3_open
   186    188   
   187    189   ifcapable {utf16} {
   188    190   do_test capi3c-4.1 {
................................................................................
   623    625   do_test capi3c-6.2 {
   624    626     sqlite3_step $STMT
   625    627   } {SQLITE_ROW}
   626    628   check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1}
   627    629   do_test capi3c-6.3 {
   628    630     sqlite3_finalize $STMT
   629    631   } {SQLITE_OK}
   630         -do_test capi3c-6.4 {
   631         -  db cache flush
   632         -  sqlite3_close $DB
   633         -} {SQLITE_OK}
   634         -do_test capi3c-6.99-misuse {
          632  +if {[clang_sanitize_address]==0} {
          633  +  do_test capi3c-6.4 {
          634  +    db cache flush
          635  +      sqlite3_close $DB
          636  +  } {SQLITE_OK}
          637  +  do_test capi3c-6.99-misuse {
          638  +    db close
          639  +  } {}
          640  +} else {
   635    641     db close
   636         -} {}
          642  +}
   637    643   
   638    644   # This procedure sets the value of the file-format in file 'test.db'
   639    645   # to $newval. Also, the schema cookie is incremented.
   640    646   # 
   641    647   proc set_file_format {newval} {
   642    648     hexio_write test.db 44 [hexio_render_int32 $newval]
   643    649     set schemacookie [hexio_get_int [hexio_read test.db 40 4]]

Changes to test/e_fkey.test.

  2942   2942     execsql COMMIT
  2943   2943     catchsql "
  2944   2944       UPDATE t0 SET a = 'yyy';
  2945   2945       SELECT NOT (a='yyy') FROM t$limit;
  2946   2946     "
  2947   2947   }
  2948   2948   
  2949         -do_test e_fkey-63.1.1 {
  2950         -  test_on_delete_recursion $SQLITE_MAX_TRIGGER_DEPTH
  2951         -} {0 0}
  2952         -do_test e_fkey-63.1.2 {
  2953         -  test_on_delete_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
  2954         -} {1 {too many levels of trigger recursion}}
  2955         -do_test e_fkey-63.1.3 {
  2956         -  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
  2957         -  test_on_delete_recursion 5
  2958         -} {0 0}
  2959         -do_test e_fkey-63.1.4 {
  2960         -  test_on_delete_recursion 6
  2961         -} {1 {too many levels of trigger recursion}}
  2962         -do_test e_fkey-63.1.5 {
  2963         -  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
  2964         -} {5}
  2965         -do_test e_fkey-63.2.1 {
  2966         -  test_on_update_recursion $SQLITE_MAX_TRIGGER_DEPTH
  2967         -} {0 0}
  2968         -do_test e_fkey-63.2.2 {
  2969         -  test_on_update_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
  2970         -} {1 {too many levels of trigger recursion}}
  2971         -do_test e_fkey-63.2.3 {
  2972         -  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
  2973         -  test_on_update_recursion 5
  2974         -} {0 0}
  2975         -do_test e_fkey-63.2.4 {
  2976         -  test_on_update_recursion 6
  2977         -} {1 {too many levels of trigger recursion}}
  2978         -do_test e_fkey-63.2.5 {
  2979         -  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
  2980         -} {5}
         2949  +# If the current build was created using clang with the -fsanitize=address
         2950  +# switch, then the library uses considerably more stack space than usual.
         2951  +# So much more, that some of the following tests cause stack overflows
         2952  +# if they are run under this configuration.
         2953  +#
         2954  +if {[clang_sanitize_address]==0} {
         2955  +  do_test e_fkey-63.1.1 {
         2956  +    test_on_delete_recursion $SQLITE_MAX_TRIGGER_DEPTH
         2957  +  } {0 0}
         2958  +  do_test e_fkey-63.1.2 {
         2959  +    test_on_delete_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
         2960  +  } {1 {too many levels of trigger recursion}}
         2961  +  do_test e_fkey-63.1.3 {
         2962  +    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
         2963  +      test_on_delete_recursion 5
         2964  +  } {0 0}
         2965  +  do_test e_fkey-63.1.4 {
         2966  +    test_on_delete_recursion 6
         2967  +  } {1 {too many levels of trigger recursion}}
         2968  +  do_test e_fkey-63.1.5 {
         2969  +    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
         2970  +  } {5}
         2971  +  do_test e_fkey-63.2.1 {
         2972  +    test_on_update_recursion $SQLITE_MAX_TRIGGER_DEPTH
         2973  +  } {0 0}
         2974  +  do_test e_fkey-63.2.2 {
         2975  +    test_on_update_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
         2976  +  } {1 {too many levels of trigger recursion}}
         2977  +  do_test e_fkey-63.2.3 {
         2978  +    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5
         2979  +      test_on_update_recursion 5
         2980  +  } {0 0}
         2981  +  do_test e_fkey-63.2.4 {
         2982  +    test_on_update_recursion 6
         2983  +  } {1 {too many levels of trigger recursion}}
         2984  +  do_test e_fkey-63.2.5 {
         2985  +    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
         2986  +  } {5}
         2987  +}
  2981   2988   
  2982   2989   #-------------------------------------------------------------------------
  2983   2990   # The setting of the recursive_triggers pragma does not affect foreign
  2984   2991   # key actions.
  2985   2992   #
  2986   2993   # EVIDENCE-OF: R-51769-32730 The PRAGMA recursive_triggers setting does
  2987   2994   # not not affect the operation of foreign key actions.

Changes to test/misc7.test.

    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # $Id: misc7.test,v 1.29 2009/07/16 18:21:18 drh Exp $
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   
    18         -do_test misc7-1-misuse {
    19         -  c_misuse_test
    20         -} {}
           18  +if {[clang_sanitize_address]==0} {
           19  +  do_test misc7-1-misuse {
           20  +    c_misuse_test
           21  +  } {}
           22  +}
    21     23   
    22     24   do_test misc7-2 {
    23     25     c_realloc_test
    24     26   } {}
    25     27   
    26     28   do_test misc7-3 {
    27     29     c_collation_test

Changes to test/misuse.test.

   167    167     set v [catch {
   168    168       db eval {SELECT * FROM t1} {} {
   169    169         set r [sqlite3_close $::DB]
   170    170       }
   171    171     } msg]
   172    172     lappend v $msg $r
   173    173   } {0 {} SQLITE_BUSY}
   174         -do_test misuse-4.4 {
          174  +
          175  +if {[clang_sanitize_address]==0} {
          176  +  do_test misuse-4.4 {
   175    177     # Flush the TCL statement cache here, otherwise the sqlite3_close() will
   176    178     # fail because there are still un-finalized() VDBEs.
   177         -  db cache flush
   178         -  sqlite3_close $::DB
   179         -  catchsql2 {SELECT * FROM t1}
   180         -} {1 {library routine called out of sequence}}
   181         -do_test misuse-4.5 {
   182         -  catchsql {
   183         -    SELECT * FROM t1
   184         -  }
   185         -} {1 {library routine called out of sequence}}
          179  +    db cache flush
          180  +      sqlite3_close $::DB
          181  +      catchsql2 {SELECT * FROM t1}
          182  +  } {1 {library routine called out of sequence}}
          183  +  do_test misuse-4.5 {
          184  +    catchsql {
          185  +      SELECT * FROM t1
          186  +    }
          187  +  } {1 {library routine called out of sequence}}
   186    188   
   187         -# Attempt to use a database after it has been closed.
   188         -#
   189         -do_test misuse-5.1 {
   190         -  db close
   191         -  sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
   192         -  execsql {
   193         -    SELECT * FROM t1
   194         -  }
   195         -} {1 2}
   196         -do_test misuse-5.2 {
   197         -  catchsql2 {SELECT * FROM t1}
   198         -} {0 {a b 1 2}}
   199         -do_test misuse-5.3 {
   200         -  db close
   201         -  set r [catch {
   202         -    sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
   203         -  } msg]
   204         -  lappend r $msg
   205         -} {1 {(21) library routine called out of sequence}}
          189  +  # Attempt to use a database after it has been closed.
          190  +  #
          191  +  do_test misuse-5.1 {
          192  +    db close
          193  +      sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]
          194  +      execsql {
          195  +        SELECT * FROM t1
          196  +      }
          197  +  } {1 2}
          198  +  do_test misuse-5.2 {
          199  +    catchsql2 {SELECT * FROM t1}
          200  +  } {0 {a b 1 2}}
          201  +  do_test misuse-5.3 {
          202  +    db close
          203  +      set r [catch {
          204  +        sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
          205  +      } msg]
          206  +    lappend r $msg
          207  +  } {1 {(21) library routine called out of sequence}}
          208  +}
   206    209   
   207    210   finish_test

Changes to test/select7.test.

   134    134     } [list 1 \
   135    135        {only a single result allowed for a SELECT that is part of an expression}]
   136    136   }
   137    137   
   138    138   # Verify that an error occurs if you have too many terms on a
   139    139   # compound select statement.
   140    140   #
   141         -ifcapable compound {
   142         -  if {$SQLITE_MAX_COMPOUND_SELECT>0} {
   143         -    set sql {SELECT 0}
   144         -    set result 0
   145         -    for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
   146         -      append sql " UNION ALL SELECT $i"
   147         -      lappend result $i
          141  +if {[clang_sanitize_address]==0} {
          142  +  ifcapable compound {
          143  +    if {$SQLITE_MAX_COMPOUND_SELECT>0} {
          144  +      set sql {SELECT 0}
          145  +      set result 0
          146  +        for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
          147  +          append sql " UNION ALL SELECT $i"
          148  +            lappend result $i
          149  +        }
          150  +      do_test select7-6.1 {
          151  +        catchsql $sql
          152  +      } [list 0 $result]
          153  +      append sql { UNION ALL SELECT 99999999}
          154  +      do_test select7-6.2 {
          155  +        catchsql $sql
          156  +      } {1 {too many terms in compound SELECT}}
   148    157       }
   149         -    do_test select7-6.1 {
   150         -      catchsql $sql
   151         -    } [list 0 $result]
   152         -    append sql { UNION ALL SELECT 99999999}
   153         -    do_test select7-6.2 {
   154         -      catchsql $sql
   155         -    } {1 {too many terms in compound SELECT}}
   156    158     }
   157    159   }
   158    160   
   159    161   # This block of tests verifies that bug aa92c76cd4 is fixed.
   160    162   #
   161    163   do_test select7-7.1 {
   162    164     execsql {