[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] Is this a wrong code bug?



Hi,
I ran the compiler_test.pl(~/csmith/scripts/) file  parallely using launchn.pl with some changes in both the files which I am attaching to this email(diff).
I found nearly > 500 such wrong_n.c programs generated from the script, and that too in each folder of each core(total 24 core machine) as I am running script parallely.
1. How do I investigate these programs for UB, and separate the  good ones?
2. Does the huge number of wrong programs generated indicate that there is some UB in the code of extended_csmith or is this  an error related to the changes with the script?

NOTE: The first random program was found to be a csmith_bug_1.c file in 18 from 24cores folders.
Can that be a reason for this?

Thanks,
Sameeran Joshi



On Sun, Jan 27, 2019 at 9:18 PM John Regehr <regehr@cs.utah.edu> wrote:
> a;
> main() {
>    a = 0x7D393Ep69;
>    printf(a);
> }
> How do I ensure it is a wrong code bug ?

This is definitely not a compiler bug, but rather undefined behavior,
since an integer is being cast to const char * then dereferenced by
printf().

Your C-Reduce interestingness test needs to include undefined behavior
checks, in practice it is often sufficient to run ASan, UBSan, and also
to look for some printf-related compiler warnings. These tools,
together, aren't 100% reliable but they're often good enough.

John

45c45
< my $COMPILER_TIMEOUT = 150;#extensions need more time
---
> my $COMPILER_TIMEOUT = 120;
77c77
< my $COMPILE_OPTIONS = "-O1";
---
> my $COMPILE_OPTIONS = "";
237,262d236
< my $index = $n%11;
< use Switch;
< switch($index){
< case 0	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --computed-goto";}
< 
< case 1	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --stmt_expr";}
< 
< case 2	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --typeof";}
< 
< case 3	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --int128 --uint128";}
< 
< case 4	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --loc-labels";}
< 
< case 5	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --binary";}
< 
< case 6	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --union-cast";}
< 
< case 7	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --variable-attribute-aligned" ;}
< 
< case 8	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --variable-attribute-unused";}
< 
< case 9	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --variable-attribute-section";}
< 
< case 10	{$CSMITH_USER_OPTIONS = "--no-paranoid --bitfields  --packed-struct --label-attribute-hot-cold";}
< }
< print "$CSMITH_USER_OPTIONS";
286c260
<     print "\nseed= $seed, size= $filesize\n";
---
>     print "seed= $seed, size= $filesize\n";
58c58
<     system "nice -19 nohup ../compiler_test.pl 55000 ../$CONFIG_FILE --with-wrong-code-bugs> output.txt 2>&1 &";
---
>     system "nice -19 nohup ../compiler_test.pl 0  ../$CONFIG_FILE > output.txt 2>&1 &";