squaresLab / genprog-code

GenProg: heuristic, GP-based automatic program repair for C.
92 stars 27 forks source link

Fatal error: exception Invalid_argument("Random.int") while processing IntroClass/smallest.c #11

Open Dearth opened 6 years ago

Dearth commented 6 years ago

Hello,

I have been attempting to recreate a few repairs from the IntroClass, specifically using the smallest programs. I have attached the test suite, configuration, and source code below. I have been unable to run genprog for more than 2-3 generations before "Fatal error: exception Invalid_argument("Random.int")" occurs and stops the run. We have tested this on a 2.X version of genprog and on v3.2 (including the most recent version of master).

The error typically appears at the beginning of a new generation.

Is this a known issue and if so does there exist an effective work around?

Thanks for your time,

Padraic

smallest.tar.gz

jlacomis commented 5 years ago

This exception happens in the random function when size is 0. This is an invalid argument to the Random.int function. It looks like one of the calls to random in mutate is passing an empty set to random, and I believe this should be illegal (i.e., random shouldn't just return 0 in this case), but I'll have to debug more. A PR addressing this should also add exception handling to random to make the error less cryptic if this happens again.

https://github.com/squaresLab/genprog-code/blob/234d263680a07c82fe53f89f3fb7e633d79ef0f9/src/search.ml#L161-L164

jlacomis commented 5 years ago

Also I've found that on my machine the seed 992046101 fails at the start of generation 2, which is relatively early. I'm not sure if the same seed behaves the same on all machines.

jlacomis commented 5 years ago

Well, there's your problem! I'll have to figure out what to do about this.

https://github.com/squaresLab/genprog-code/blob/234d263680a07c82fe53f89f3fb7e633d79ef0f9/src/search.ml#L361-L368

jlacomis commented 5 years ago

This issue isn't fully solved by #21 (which doesn't use the cache), but that patch should avoid crashes because of this.