ajanata / PretendYoureXyzzy

A web clone of the card game Cards Against Humanity.
https://pretendyoure.xyz/zy
BSD 2-Clause "Simplified" License
1.23k stars 397 forks source link

Potential race condition if resetState() is called while a timer task is executing #108

Open ajanata opened 10 years ago

ajanata commented 10 years ago

Specifically, it looks like if the game is trying to deal cards, it's possible that whiteDeck has been set to null in resetState.

2014-05-05 14:30:47,274 [timer-task-10] ERROR net.socialgamer.cah.SafeTimerTask - Exception running SafeTimerTask
java.lang.NullPointerException
        at net.socialgamer.cah.data.Game.getNextWhiteCard(Game.java:1120)
        at net.socialgamer.cah.data.Game.dealState(Game.java:737)
        at net.socialgamer.cah.data.Game.startNextRound(Game.java:1103)
        at net.socialgamer.cah.data.Game.skipIdleJudge(Game.java:883)
        at net.socialgamer.cah.data.Game.access$4(Game.java:863)
        at net.socialgamer.cah.data.Game$4.process(Game.java:855)
        at net.socialgamer.cah.SafeTimerTask.run(SafeTimerTask.java:13)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)

Around the same time, the server went unresponsive. Java is also pegging a CPU. It looks like it's the JVM itself pegging a thread, possibly in the garbage collector... "VM Thread", which isn't very helpful.