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

Rare case where entities are null and Entity iterator counter go nuts 🤪 #168

Closed
pietro-lopes opened this issue Aug 27, 2024 · 2 comments

Comments

@pietro-lopes
Copy link

pietro-lopes commented Aug 27, 2024

To reproduce this you might need to keep going through other dimension and going back very fast.
I managed to get this while on creative and going to nether and going back.
May take a while

I managed to capture a moment where entity was null and the iterator goes in infinite loop (hasNext returns always true)

if (entity == null || !(entity instanceof Cullable)) {

here is a sequence of images where it first hits null
null2
null3
null4

and so on, index goes until it hits max int and goes into negative

This causes CullThread to get stuck in this infinite while loop.

@tr7zw
Copy link
Owner

tr7zw commented Aug 28, 2024

AHHHHH I did experience this issue before and even managed to attach a profile, but that didn't allow me to see memory values, just that the stack seemed to move in a normal way around the thread, so I had no clue why it was behaving weirdly and fixing itself after some time (I assumed the thread crashed/deadlocked/got stuck on something, which wasn't the case). Amazing catch, will publish fixed versions later today.

@tr7zw
Copy link
Owner

tr7zw commented Aug 28, 2024

Adding the simple workaround right now,

hasNext returns always true

this is really interesting. I fully expect getting null/ConcurrentModificationException/ArrayIndexOutOfBoundsException when iterating over the entity list in this unsafe non thread safe way, but the iterator overshooting and going through the entire int value space is certainly a new (and unexpected) one. I'll change it to instead break the loop when it gets a null value after hasNext was true.

@tr7zw tr7zw closed this as completed in 1c96819 Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants