Bug witnessed in commit: c0f5455
Bug description
Creating instances of the RandomXoshiro256StarStar random number generator while providing a seed parameter throws an exception.
Error description
Source code:
RandomXoshiro256StarStar random = new RandomXoshiro256StarStar( 1000l );
Exception thrown:
java.lang.NullPointerException
at fr.univ_artois.lgi2a.similar.extendedkernel.libs.random.rng.RandomXoshiro256StarStar.setSeed(RandomXoshiro256StarStar.java:58)
at java.util.Random.<init>(Random.java:141)
at fr.univ_artois.lgi2a.similar.extendedkernel.libs.random.rng.RandomXoshiro256StarStar.<init>(RandomXoshiro256StarStar.java:35)
The error also appears when:
- Calling the
RandomXoshiro256StarStar()
constructor;
- Calling the
RandomGeneratorWrapper(String,long)
constructor of class RandomGeneratorWrapper
, using RandomGeneratorWrapper.XOROSHIRO_256
as the first parameter.
Environment
Environment where the bug occurred :
- Eclipse version 2018-12 (4.10.0) - Build id: 20181214-0600
- Java :
- OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.04.1-b12)
- OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
- Ubuntu 18.04 LTS
Possible cause
Line 55 of RandomXoshiro256StarStar defines the setSeed
method as :
public void setSeed(long seed) {
super.setSeed(seed);
long sms = splitmix64_1(seed);
s[0] = splitmix64_2(sms);
sms = splitmix64_1(sms);
s[1] = splitmix64_2(sms);
sms = splitmix64_1(sms);
s[2] = splitmix64_2(sms);
sms = splitmix64_1(sms);
s[3] = splitmix64_2(sms);
}
The error seems to be caused by the non initalization of the array s
. Yet, it seems initialized later, at line 144 :
private final long[] s = new long[4];