Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wood Logs bug #260

Open
Mehbro opened this issue Aug 6, 2021 · 1 comment
Open

Wood Logs bug #260

Mehbro opened this issue Aug 6, 2021 · 1 comment
Labels
bug Script side bug that should be fixable

Comments

@Mehbro
Copy link

Mehbro commented Aug 6, 2021

There's a bug with wood logs in which sometimes when i cut up a log for wood it generates an absurd amount of wood (20000+) which lags the server and gives a very OP advantage.

@Vam-Jam Vam-Jam added the bug Script side bug that should be fixable label Aug 6, 2021
@Hobey
Copy link
Contributor

Hobey commented Aug 23, 2021

If I understand the code correctly, the bug is caused by MinableMats.as onHit getting called before Log.as onInit, which happens only if a player or dynamite hit a minable blob in the first tick after it gets created, resulting in this.get("minableMats", @mats); returning a null pointer. That pointer is not null checked but instead gets interpreted by the code as a HarvestBlobMat struct, which should almost never result in a valid f32 amount and string matname, but when it does, it can end up spitting out a huge quantity of mats.

Could add if (mats is null) return; after line 35 in MinableMats.as onHit as an ad-hoc way of fixing the bug.

Also note that someone told me ingame that they experienced the bug with a ladder as well (instead of a log).

Edit:
I just remembered that if a null pointer gets dereferenced in a script, the script just halts.

So probably the actual cause of the bug is HarvestBlobMat[]@ mats; in MinableMats.as onHit not setting an initial value of the mats pointer, and this.get("minableMats", @mats); not modifying the mats pointer out-parameter, since the "minableMats" property does not exist yet. That results in the mats pointer just being arbitrary uninitted stack memory probably, which ends up getting interpreted as a HarvestBlobMat pointer.

So, additionally to if (mats is null) return; after line 35, also change line 34 to HarvestBlobMat[]@ mats = null;,
or, alternatively just do a if (!this.exists("minableMats")) return;.

Dunno what a good way of reproducing the bug would be since it's so rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Script side bug that should be fixable
Projects
None yet
Development

No branches or pull requests

3 participants