### indy256's blog

By indy256, 6 years ago,

The following code crashes Java8 on Codeforces:

public class Main {
public static void main(String[] args) {
java.math.BigInteger.valueOf(7).nextProbablePrime();
}
}


http://codeforces.ru/contest/427/submission/6539822

Maybe updating Java8 will solve the problem.

• +27

 » 6 years ago, # |   +14 It's well known issue, that nextProbablePrime() use low level access to OS for rand seed and code of "probematic frame" sayed, that crash was in native code and it may be caused by security policy of OS.
•  » » 6 years ago, # ^ |   +3 I checked that, SecureRandom works fine.
•  » » » 6 years ago, # ^ | ← Rev. 8 →   +3 I have the same version of JRE at workstation ( but i have client version, not server ) and no problems. As I can see native calls in ThreadLocalRandom.current() are the reason of crush. It used in internals of java.math.BigInteger#passesMillerRabin
•  » » » » 6 years ago, # ^ | ← Rev. 4 →   0 Actually I meant that nextProbablePrime uses SecureRandom. On Codeforces servers SecureRandom doesn't crash Java, but nextProbablePrime does. Or what did you mean?UPD. Seen your UPD. I thought that it only uses SecureRandom, but I didn't know Java well enough, I see. :)Was SecureRandom replaced by ThreadLocalRandom in Java 8?UPD2. In Java 7 and 6, ThreadLocalRandom.current() doesn't crash.
•  » » » » » 6 years ago, # ^ |   +3 I don't know in detail how Codeforces protect they java-run sandboxes :)
•  » » 6 years ago, # ^ |   +8 Mike wrote that OS' low-level rand seed is problematic and they are using java -Djava.security.egd=file:filename to set seed for SecureRandom. (Russian: http://codeforces.ru/blog/entry/10037)
•  » » » 6 years ago, # ^ |   -8 We don't have full crush dump or information about protection system. It's all guesswork.
•  » » » » 6 years ago, # ^ |   0 Who 'we'? And do you mean crAsh dump?
•  » » » » » 6 years ago, # ^ |   0 Yes, crash dump. We — users interested in solving problem :)
 » 6 years ago, # |   -41 Typical Java
•  » » 6 years ago, # ^ |   0 typical troll!
•  » » » 6 years ago, # ^ |   0 yes, but still, he has +72 of contribution (at the time of writing), which is almost the same of yours (+73 at the time of writing). Contribution is not supposed to be a measure of "anti-trollness" also? Amazing CodeForces.
•  » » » » 6 years ago, # ^ |   0 yeah, i noticed that he has a lot of upvotes in Russian interface. i don't know Russian very well, so unfortunately i can't judge him there. however, he is nothing but a troll in English! :D