Entity Culling Fabric/Forge

Entity Culling Fabric/Forge

80M Downloads

Rare case where entities are null and Entity iterator counter go nuts :zany_face:

pietro-lopes opened this issue ยท 2 comments

commented

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.

commented

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.

commented

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.