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

ArrayIndexOutOfBoundsException in NearestSortingList #2742

Closed
oniatus opened this issue Jan 7, 2017 · 6 comments
Closed

ArrayIndexOutOfBoundsException in NearestSortingList #2742

oniatus opened this issue Jan 7, 2017 · 6 comments
Labels
Multiplayer Affects aspects not visible in Singleplayer mode only Type: Bug Issues reporting and PRs fixing problems

Comments

@oniatus
Copy link
Contributor

oniatus commented Jan 7, 2017

Maybe an issue in the sort logic or an issue in the add-remove logic of the list?

What actually happened

Random Multiplayer Testing with the gci content and NeoTTA with ~6 players.

How to reproduce

I have no idea :) It occured only once so far.

Log details

Only this one, all other lines were unrelated (chat events, destroyed entities, multiple chunks loaded)
19:58:01.762 [Timer-1] ERROR o.t.r.logic.NearestSortingList - Uncaught exception in sorting thread: java.lang.ArrayIndexOutOfBoundsException: 200

@oniatus
Copy link
Contributor Author

oniatus commented Jan 7, 2017

I changed the logging at the code location a bit. We should get a stacktrace when this hits again.

@Cervator
Copy link
Member

Cervator commented Jan 8, 2017

Thanks! I just updated the event server to Omega 652, which includes that and some other stuff :-)

Feel free to join up to try to crash sometime: http://jenkins.terasology.org/job/DistroOmega/652/artifact/distros/omega/build/distributions/TerasologyOmega.zip

(I'll be sleeping soon but maybe more tomorrow)

@Cervator Cervator added Type: Bug Issues reporting and PRs fixing problems Multiplayer Affects aspects not visible in Singleplayer mode only labels Jan 8, 2017
@Cervator Cervator added this to the Alpha 6 - noteworthy known issues milestone Jan 8, 2017
@Cervator
Copy link
Member

Is this what we're looking for? Happened while testing in single player with some, uh, creative railgun usage (drilling straight down to get to the underworld - my new PC can do this with no apparent slowdown holding down the right mouse button)

18:50:03.435 [Saving-0] INFO  o.t.p.internal.SaveTransaction - Save game finished
18:50:15.569 [Timer-0] ERROR o.t.r.logic.NearestSortingList - Uncaught exception in sorting thread
java.lang.ArrayIndexOutOfBoundsException: 2704
	at gnu.trove.impl.hash.TLongHash.index(TLongHash.java:216)
	at gnu.trove.map.hash.TLongObjectHashMap.get(TLongObjectHashMap.java:212)
	at org.terasology.entitySystem.entity.internal.ComponentTable.get(ComponentTable.java:41)
	at org.terasology.entitySystem.entity.internal.PojoEntityManager.getComponent(PojoEntityManager.java:591)
	at org.terasology.entitySystem.entity.internal.BaseEntityRef.getComponent(BaseEntityRef.java:100)
	at org.terasology.logic.location.DistanceComparator.compare(DistanceComparator.java:77)
	at org.terasology.logic.location.DistanceComparator.compare(DistanceComparator.java:32)
	at java.util.TimSort.mergeLo(TimSort.java:717)
	at java.util.TimSort.mergeAt(TimSort.java:514)
	at java.util.TimSort.mergeCollapse(TimSort.java:439)
	at java.util.TimSort.sort(TimSort.java:245)
	at java.util.Arrays.sort(Arrays.java:1438)
	at java.util.List.sort(List.java:478)
	at java.util.Collections.sort(Collections.java:175)
	at org.terasology.rendering.logic.NearestSortingList$SortTask.sort(NearestSortingList.java:450)
	at org.terasology.rendering.logic.NearestSortingList$SortTask.run(NearestSortingList.java:418)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)
18:50:15.615 [Timer-0] WARN  o.t.r.logic.NearestSortingList - The commands list was not emptied properly!

@oniatus
Copy link
Contributor Author

oniatus commented Jan 11, 2017

Deeper than expected and a good spot for digging :)

Basic Idea of the class seems to be to clone the internal list before sorting (synchronized), then sort the list (unsynchronized) and then apply pending add/remove/clear operations to the list (synchronized).

One guess by a short look: If two threads sort the list in parallel (can this happen at all?) and there are pending add/remove commands, will the first thread apply the commands and the second one replace the updated list with the old one?

@elwe74
Copy link

elwe74 commented Apr 4, 2017

I had the same exception. I have looked into the class TLongHash and found an error which may cause the exception:

In the super-constructor (TPrimitiveHash and THash) the method setUp(..) is called which is overridden in TLongHash to do some initialisation in class TLongHash.

This is not allowed: If TLongHash-constructor calls super(), no fields of TLongHash are existing yet and so cannot be correctly initialised by the setUp(..)-call in the super-constructor.

@oniatus
Copy link
Contributor Author

oniatus commented Apr 5, 2017

Did some deeper debugging and testing, probably found the isse - at least i can't reproduce it anymore with #2884 in place. Prior to the changes i got the exception every time after excessive railgun use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Multiplayer Affects aspects not visible in Singleplayer mode only Type: Bug Issues reporting and PRs fixing problems
Projects
None yet
Development

No branches or pull requests

3 participants