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

Re: [csmith-dev] wishlist: option to disable globals

Hi Yang Chen et al,

On Mon, May 30, 2016 at 4:28 PM, Yang Chen <chenyang@cs.utah.edu> wrote:
> I just committed some code that allows the generator to not generate global
> variables if --no-global-variables is passed. See if it works for you. Note
> that with --no-global-variables, all the generated programs will produce the
> same checksum 0, because we compute checksums using global variables.

This is *so cool*. With the option you added, I've found all sorts of
interesting bugs in my code. :-) I'm crediting csmith in my commit
messages when I fix issues it triggered, if anyone happens to want to
find such things later.


I think I've found a bug in csmith, too. It isn't supposed to generate
C programs that have undefined behavior, right? Apparently it can
generate shifts by a number of bits larger than the size of the
integer-promoted left-hand side. In particular, it generated this:

(uint16_t)p_9 << (uint16_t)(... , 0xD051L)

(I've elided the irrelevant left-hand side of the comma operator.)
When I translated that to Rust, the Rust compiler reported: "bitshift
exceeds the type's number of bits, #[deny(exceeding_bitshifts)] on by
default", which I thought was pretty nice.

But at this point, I can translate a csmith-generated source file that
I've only slightly hacked up, into a Rust module which compiles
without errors! I'm so excited about this. :-)

I like Alastair's proposal to optionally use structs instead of
globals. I haven't implemented either structs or pointers yet
(arithmetic has been tricky enough!) but when I do, I think that would
be an ideal approach.

Thank you all for csmith! This is awesome.