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

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



Hi,
I tried using creduce for reducing the program wrong4.c :

The test.sh file contains :
#!/bin/bash

ulimit -t 2
#first is correct
clang -O1 wrong4.c -o correct_exe -I/home/gccbuild/Desktop/csmith-extended/csmith/runtime/ >/dev/null 2>&1 &&\
./correct_exe >out1.txt 2>&1 &&\

#second is broken
clang wrong4.c -o wrong_exe -I/home/gccbuild/Desktop/csmith-extended/csmith/runtime/ >/dev/null 2>&1 &&\
./wrong_exe >out2.txt 2>&1 &&\
! diff out1.txt out2.txt



reduced output is :
  ******** /home/gccbuild/Desktop/csmith-extended/csmith/runtime/reduced-test/wrong4.c ********

a;
main() {
  a = 0x7D393Ep69;
  printf(a);
}
How do I ensure it is a wrong code bug ?

Thanks,
Sameeran Joshi

On Sun, Jan 27, 2019 at 12:12 AM sameeran joshi <gsocsameeran@gmail.com> wrote:
Hi,
I tried checking the program for undefined behavior using Valgrind as :
  $ valgrind --leak-check=yes ./a.out
  $ valgrind --track-origins=yes ./a.out

where a.out is the executable for wrong.c file compiled using :
clang -g -O1 wrong4.c -o a.out

following the steps at:
http://valgrind.org/docs/manual/quick-start.html#quick-start.intro

The image below consists of the output of valgrind.

Please can you verify the output in the image ? If everything is
correct, this leads me to suspect that there could be a bug in clang,
if so, can I use creduce to reduce the bug or do I need to use
bugpoint mentioned at
http://llvm.org/docs/HowToSubmitABug.html#miscompiling

Thanks,
Sameeran Joshi



On 1/25/19, John Regehr <regehr@cs.utah.edu> wrote:
> Yes, this is either a wrong code bug in clang or else a bug where Csmith
> emitted an insufficiently defined program, you'll need to determine
> which of these is the case.
>
> Also I'm confused about why gcc and clang would return different results
> -- generally they make the same decisions for implementation-defined
> behaviors. This is worth investigating as well.
>
> John
>
>
> On 1/25/19 3:56 AM, sameeran joshi wrote:
>> Hi,
>> compiling a program as
>> gcc -O0  --------> CHECKSUM : 72D53249
>> gcc -O1  --------> CHECKSUM : 72D53249
>> gcc -O2 --------> CHECKSUM : 72D53249
>> gcc -O3  --------> CHECKSUM : 72D53249
>> gcc -Os  --------> CHECKSUM : 72D53249
>> gcc -Ofast  --------> CHECKSUM : 72D53249
>>
>> **clang -O0  --------> CHECKSUM : 2873C061**(differs)
>>
>> clang -O1  --------> CHECKSUM : 10301700
>> clang -O2  --------> CHECKSUM : 10301700
>> clang -O3  --------> CHECKSUM : 10301700
>> clang -Os  --------> CHECKSUM : 10301700
>> clang -Ofast  --------> CHECKSUM : 10301700
>>
>> is this a wrong code bug found using differential testing approach?
>> Thanks,
>> Sameeran Joshi
>>
>