/ Check-in [f4a701d5]
Login

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 Show Whitespace Changes 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  +/*
          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  +}
   245    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.
................................................................................
  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  +if {[clang_sanitize_address]==0} {
   182    183   do_test capi3-3.6.1-misuse {
   183    184     sqlite3_close $db2
   184    185   } {SQLITE_MISUSE}
   185    186   do_test capi3-3.6.2-misuse {
   186    187     sqlite3_errmsg $db2
   187    188   } {library routine called out of sequence}
   188    189   ifcapable {utf16} {
   189    190     do_test capi3-3.6.3-misuse {
   190    191       utf8 [sqlite3_errmsg16 $db2]
   191    192     } {library routine called out of sequence}
   192    193   }
          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 {
   199    201     sqlite3_close $db2
................................................................................
   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   
          666  +if {[clang_sanitize_address]==0} {
   664    667   do_test capi3-6.4-misuse {
   665    668     db cache flush
   666    669     sqlite3_close $DB
   667    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]
................................................................................
  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   1067   #
         1068  +if {[clang_sanitize_address]==0} {
  1064   1069   do_test capi3-14.1-misuse {
  1065   1070     set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
  1066   1071     lappend rc $msg
  1067   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  +if {[clang_sanitize_address]==0} {
   172    173   do_test capi3c-3.6.1-misuse {
   173    174     sqlite3_close $db2
   174    175   } {SQLITE_MISUSE}
   175    176   do_test capi3c-3.6.2-misuse {
   176    177     sqlite3_errmsg $db2
   177    178   } {library routine called out of sequence}
   178    179   ifcapable {utf16} {
   179    180     do_test capi3c-3.6.3-misuse {
   180    181       utf8 [sqlite3_errmsg16 $db2]
   181    182     } {library routine called out of sequence}
   182    183   }
          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 {
   189    191     set db2 [sqlite3_open16 [utf16 test.db] {}]
................................................................................
   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}
          632  +if {[clang_sanitize_address]==0} {
   630    633   do_test capi3c-6.4 {
   631    634     db cache flush
   632    635     sqlite3_close $DB
   633    636   } {SQLITE_OK}
   634    637   do_test capi3c-6.99-misuse {
   635    638     db close
   636    639   } {}
          640  +} else {
          641  +  db close
          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  +# 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} {
  2949   2955   do_test e_fkey-63.1.1 {
  2950   2956     test_on_delete_recursion $SQLITE_MAX_TRIGGER_DEPTH
  2951   2957   } {0 0}
  2952   2958   do_test e_fkey-63.1.2 {
  2953   2959     test_on_delete_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]
  2954   2960   } {1 {too many levels of trigger recursion}}
  2955   2961   do_test e_fkey-63.1.3 {
................................................................................
  2974   2980   } {0 0}
  2975   2981   do_test e_fkey-63.2.4 {
  2976   2982     test_on_update_recursion 6
  2977   2983   } {1 {too many levels of trigger recursion}}
  2978   2984   do_test e_fkey-63.2.5 {
  2979   2985     sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000
  2980   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  +if {[clang_sanitize_address]==0} {
    18     19   do_test misc7-1-misuse {
    19     20     c_misuse_test
    20     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  +
          175  +if {[clang_sanitize_address]==0} {
   174    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    179     db cache flush
   178    180     sqlite3_close $::DB
   179    181     catchsql2 {SELECT * FROM t1}
   180    182   } {1 {library routine called out of sequence}}
................................................................................
   199    201   do_test misuse-5.3 {
   200    202     db close
   201    203     set r [catch {
   202    204       sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL
   203    205     } msg]
   204    206     lappend r $msg
   205    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  +if {[clang_sanitize_address]==0} {
   141    142   ifcapable compound {
   142    143     if {$SQLITE_MAX_COMPOUND_SELECT>0} {
   143    144       set sql {SELECT 0}
   144    145       set result 0
   145    146       for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
   146    147         append sql " UNION ALL SELECT $i"
   147    148         lappend result $i
................................................................................
   151    152       } [list 0 $result]
   152    153       append sql { UNION ALL SELECT 99999999}
   153    154       do_test select7-6.2 {
   154    155         catchsql $sql
   155    156       } {1 {too many terms in compound SELECT}}
   156    157     }
   157    158   }
          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 {
   163    165       CREATE TABLE t3(a REAL);
   164    166       INSERT INTO t3 VALUES(44.0);