trailofbits/deepstate

OneOf Compilation Failed

akhikolla opened this issue · 4 comments

Hello Everyone,
I am having issues with compiling OneOf.cpp in the examples folder of deepstate. I keep getting the following error.

image

I didn't make any changes to the existing file all I did was compile it and I get the above errors. Can someone let me know what's wrong?

I am also using OneOf to select one element from a vector.
Rcpp::NumericVector exceptional_values = Rcpp::NumericVector::create( 1, NA_REAL, R_NaN, R_PosInf, R_NegInf);
for(int i = 0 ; i < rand_size - 1 ;i++){
rand_numvec[i] = deepstate::OneOf(exceptional_values);
}
I get the below errors.
image

  1. You'll need to add -ldeepstate to your compilation options

  2. Try adding -std=c++11 to your command line also

Thanks for the information. I am able to compile the code.
using clang++ OneOf.cpp -ldeepstate
I am trying to get one element each time from the array using OneOf but it keeps choosing the first element shouldn't OneOf pick the elements randomly?:
Here is the code:

#include <deepstate/DeepState.hpp> using namespace deepstate; TEST(OneOfExample, array_test) { int arr[] = {42,95,45,50}; for (int n = 0; n < 10; n++) { printf("%d",OneOf(arr)); } }

Here's the output: It displays the first element of the array for all the iterations.
image

Akhila,

As I have explained before, you only get random values if you run with --fuzz or another fuzzer. The executable with no options runs "the default test" which tends to be a lot of zeros.

When you said we get random values only with --fuzz I thought it's only for
DeepState_*() functions(DeepState_Double(), DeepState_Int() etc) not for OneOf and ForAny.
Thanks for the clarification it's working.