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

Re: [csmith-dev] Resetting global variables explicitly before main function gets called



I think you have changed your requirement. But I will answer it anyway.

The easiest way to satisfy your request is to hack Csmith so that each time it's called, it generates a whole new set of variables.

The random variables are named as "g_<seq#>" for global variables or "l_<seq#>" for locals. For example, the global variables would be named "g_1", "g_2", and so on.

After a invocation of Csmith, you can dump the last sequence number, and force Csmith to start with that number +1 on the next invocation. This way, there will never be name conflicts between two calls to Csmith.  Problem solved, unless you do want the second instance of Csmith manipulate the variables from the 1st instance...

-Xuejun


On Wed, Aug 3, 2016 at 8:42 AM, John Regehr <regehr@cs.utah.edu> wrote:

Hello Shafiul,

I can't think of a really easy way to make this happen. Perhaps you can hack Csmith a bit so that it generates initializers in a function that runs at the start of main, instead of running at initializer time.

John



On 08/03/2016 09:28 AM, Shafiul Azam wrote:
Hi All,

I'm trying to use Csmith in my project where I dynamically link Csmith generated code. The Csmith generated main function is called repeatedly up to a certain number of times. Now, when the main function is called second (or third, fourth etc.) time, global variables have values different than their initial values (as a result of the computations performed when main was called first time). As a result, the program behaviors differently (different checksum, crashes etc.).

Is there any way to reset values of the global variables before main is called, so that, if I dynamically link a Csmith generated function and call it multiple times, it would have produced same behaviors (checksum) each time? Or, at least, should not exhibit any unspecified or undefined behaviors?

Thank you!

Shafiul