This repository has been archived by the owner on May 29, 2022. It is now read-only.
Don't allow plugins to set problematic velocity vectors #412
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently plugins can use the api to set a players velocity to illegal values like
NaN
which causes the server to freeze under some circumstances.In
Entity.java:541
we can find this loop:The check
d0 != 0.0D
is important here:d0
will be initialized with the entitiesmotionX
.If
motionX
(or in the following loopsmotionY
,motionZ
) isNaN
, this check is alwaysfalse
sinceNaN += x = NaN
resulting in an endless loop and the server to freeze/crash.The fix implemented in this PR is to disallow plugins to set any
NaN
values through thesetVelocity(...)
api.Another way of fixing this would be to check if
d0
isNaN
and overriding it with0
. But i think it's better to not allow settingNaN
in the first place at the api layer.Fixes #409
How has this been tested?
On a production server with 20-30 players for 24 hours without any crashes.
Checklist: