diff --git a/BUGS_REPORTED.TXT b/BUGS_REPORTED.TXT index b5c83d6da..c3e51ea77 100644 --- a/BUGS_REPORTED.TXT +++ b/BUGS_REPORTED.TXT @@ -1,5 +1,9 @@ =================================================================== +11/07/2011 (total 396) + 1 clang crash bug reported + http://llvm.org/bugs/show_bug.cgi?id=11327 + 08/10/2011 (total 395) 1 gcc crash bug reported by Arthur O'Dwyer http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50039 diff --git a/runtime/csmith_minimal.h b/runtime/csmith_minimal.h index f390892a1..9ba038e01 100644 --- a/runtime/csmith_minimal.h +++ b/runtime/csmith_minimal.h @@ -28,6 +28,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +extern int printf (const char *, ...); + // FIXME-- need more versions, and a way to figure out which is needed #include "custom_stdint_x86.h" @@ -60,8 +62,6 @@ static inline void crc32_gentab (void) int crc32_context; -extern int printf (const char *, ...); - #ifdef TCC int strcmp (const char *s1, const char *s2) { diff --git a/utah/scripts/reduce/simple_delta.pl b/utah/scripts/reduce/simple_delta.pl index d0bb20d56..19cd18032 100755 --- a/utah/scripts/reduce/simple_delta.pl +++ b/utah/scripts/reduce/simple_delta.pl @@ -19,26 +19,34 @@ my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; die "please set CSMITH_HOME env first!" if (!defined($CSMITH_HOME)); -my $VOLATILE = $ENV{"VOLATILE_HOME"}; -die "please set VOLATILE_HOME env first!" if (!defined($VOLATILE)); +#my $VOLATILE = $ENV{"VOLATILE_HOME"}; +#die "please set VOLATILE_HOME env first!" if (!defined($VOLATILE)); -$ENV{"PATH"} = "$ENV{VOLATILE_HOME}:$ENV{PATH}"; +#$ENV{"PATH"} = "$ENV{VOLATILE_HOME}:$ENV{PATH}"; my $COMPILER_TIMEOUT = 600; my $PROG_TIMEOUT = 2; -if (@ARGV != 4 && @ARGV != 3) { - die "usage: simple_delta.pl \n\n"; +# in second +my $TEST_TIMEOUT = 20 * 60; + +if (@ARGV != 4 && @ARGV != 3 && @ARGV != 5) { + die "usage: simple_delta.pl \n\n"; } my $seed = $ARGV[0]; my $COMPILER1 = $ARGV[1]; my $COMPILER2 = $ARGV[2]; my $OPTS = "--concise "; -if (@ARGV == 4) { +if (@ARGV >= 4) { $OPTS = "$OPTS$ARGV[3]"; } +my $crash_string = ""; +if (@ARGV == 5) { + $crash_string = $ARGV[4]; +} + my $cfile = "small.c"; my $tmp_cfile = "small_tmp.c"; my $backup_cfile = "works.c"; @@ -81,6 +89,21 @@ ($\@$) return $cnt; } +sub read_file_with_substring($\@$) { + my ($input, $out, $substring) = @_; + my $cnt = 0; + open INF1, "<$input" or die; + while (my $line = ) { + chomp $line; + if (index($line, $substring) != -1) { + push @$out, $line; + $cnt++; + } + } + close INF1; + return $cnt; +} + sub compile($$$$) { my ($compiler, $src_file, $exe, $out) = @_; my $res = 0; @@ -157,7 +180,7 @@ ($\@$\@$$) my $EXTRA='-Wuninitialized -Werror=uninitialized'; # flag1 == 1: we check if two outputs have the same lines. # flag2 == 1: we check the line which is "checksum = xxxx". -sub run_test ($$$) { +sub run_wrong_code_test ($$$) { my ($test_file, $flag1, $match) = @_; system "rm -f gcc.txt"; system "gcc $ARGS $EXTRA -O0 $test_file -o a.out > gcc.txt 2>&1"; @@ -207,6 +230,50 @@ ($$$) return $res; } +sub run_crash_test($$) { + my ($test_file, $match) = @_; + system "rm -f gcc.txt"; + system "gcc $ARGS $EXTRA -O0 $test_file -o a.out > gcc.txt 2>&1"; + my @tmp = (); + if (read_file("gcc.txt", @tmp, "no return statement") || + read_file("gcc.txt", @tmp, "control reaches") || + # read_file("gcc.txt", @tmp, "initia") || + read_file("gcc.txt", @tmp, "proto")) { + system("cp $test_file gcc_fail.c"); + print "$indent compiler error! Can't compile $test_file with gcc\n"; + return 0; + } + + $test_count++; + my $res; + $res = compile($COMPILER1, $test_file, "$EXE1$test_count", "$COMPILER_OUT1$test_count"); + if ($res) { + if (read_file_with_substring("$COMPILER_OUT1$test_count", @tmp, $match)) { + print "$indent crash string $match found for $test_file with $COMPILER1\n"; + return 1; + } + else { + print "$indent no crash string $match found for $test_file with $COMPILER1\n"; + return 0; + } + } + else { + print "$indent no crash error found for $test_file with $COMPILER1\n"; + return 0; + } +} + +sub run_test($$$) { + my ($test_file, $flag1, $match) = @_; + + if ($crash_string eq "") { + return run_wrong_code_test($test_file, $flag1, $match); + } + else { + return run_crash_test($test_file, $crash_string); + } +} + sub get_score ($) { (my $fn) = @_; return stat($fn)->size; @@ -227,6 +294,8 @@ ($) print "seed = $seed\n"; +$OPTS =~ s/-s\s+[0-9]+//g; + system "${CSMITH_HOME}/src/csmith -s $seed $OPTS --delta-monitor simple --delta-output $deltafile > $cfile"; my $res = run_test($cfile, 0, "checksum "); @@ -247,6 +316,8 @@ ($) my $orig_sz = get_score($cfile); my $n = 0; +my $prev_time = time(); +my $total_time = 0; print "initial score = $orig_sz\n"; while (1) { @@ -289,6 +360,13 @@ ($) } else { $sz = $new_sz; } + my $curr_time = time(); + $total_time += ($curr_time - $prev_time); + $prev_time = $curr_time; + print "elapsed time: $total_time\n"; + if ($total_time > $TEST_TIMEOUT) { + last; + } } system "cp $cfile simple$seed.c"; my $sz = get_score($cfile);