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

AddNetObject System.IndexOutOfRangeException: Index was outside the bounds of the array. #416

Open
danbudworthmead opened this issue May 29, 2021 · 5 comments

Comments

@danbudworthmead
Copy link
Contributor

danbudworthmead commented May 29, 2021

Bug Report

Base Information

  • Operating System - Windows 10
  • Impostor Version - latest code build
  • Among Us Version - 2021.5.25s

I confirm:

  • [ x] that I have searched for an existing bug report for this issue.

Symptoms

[14:04:47 ERR] Invoking data received failed System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at Impostor.Server.Net.State.Game.AddNetObject(InnerNetObject obj) in Z:\GitHub\skeld.net 2.0\Impostor\src\Impostor.Server\Net\State\Game.Data.cs:line 404 at Impostor.Server.Net.State.Game.HandleGameDataAsync(IMessageReader parent, ClientPlayer sender, Boolean toPlayer) in Z:\GitHub\skeld.net 2.0\Impostor\src\Impostor.Server\Net\State\Game.Data.cs:line 169 at Impostor.Server.Net.Client.HandleMessageAsync(IMessageReader reader, MessageType messageType) in Z:\GitHub\skeld.net 2.0\Impostor\src\Impostor.Server\Net\Client.cs:line 177 at Impostor.Server.Net.Hazel.HazelConnection.ConnectionOnDataReceived(DataReceivedEventArgs e) in Z:\GitHub\skeld.net 2.0\Impostor\src\Impostor.Server\Net\Hazel\HazelConnection.cs:line 71 at Impostor.Hazel.Connection.InvokeDataReceived(MessageReader msg, MessageType messageType) in Z:\GitHub\skeld.net 2.0\Impostor\src\Impostor.Hazel\Hazel\Connection.cs:line 185

image

Reproduction

100% repro rate. Have 10 clients connected, have the game end, then click Play Again on all clients. Make sure host is the last to click Play Again. They all try to spawn in, and then the symptoms start.

@miniduikboot
Copy link
Member

I started 10 clients of version 2021.5.25.2s, started a game on Skeld with the same settings as shown in your screenshot. After sabotaging the reactor and waiting for the cooldown to end, I clicked "Play again" on all clients, then finally clicked it on the host. All 10 players rejoined correctly. I even tried it multiple times with different endings, like sabotaging oxygen instead or by voting out the impostor.

While I appreciate your clear steps, I'm unable to reproduce them on a clean checkout of the Impostor codebase (a13fee1). Next time please double check if your issues occur there too.

@danbudworthmead
Copy link
Contributor Author

I started 10 clients of version 2021.5.25.2s, started a game on Skeld with the same settings as shown in your screenshot. After sabotaging the reactor and waiting for the cooldown to end, I clicked "Play again" on all clients, then finally clicked it on the host. All 10 players rejoined correctly. I even tried it multiple times with different endings, like sabotaging oxygen instead or by voting out the impostor.

While I appreciate your clear steps, I'm unable to reproduce them on a clean checkout of the Impostor codebase (a13fee1). Next time please double check if your issues occur there too.

That is very odd as I also tried it on a clean checkout of Impostor. Maybe it's something overloading my local network? For me it's 100% repro rate.

@miniduikboot
Copy link
Member

Weird, I'm running into a different issue though when I have anticheat enabled, could you flip that option on your side and retest?

Network overload could be an option, I'm testing against a server running on localhost. It may also be worth mentioning that I'm running everything on Linux.

@danbudworthmead
Copy link
Contributor Author

Weird, I'm running into a different issue though when I have anticheat enabled, could you flip that option on your side and retest?

Network overload could be an option, I'm testing against a server running on localhost. It may also be worth mentioning that I'm running everything on Linux.

Just had my issue happen again with 4 players on Polus. I think it's a threading issue.
https://stackoverflow.com/a/39923529

I've changed it to use a concurrentdictionary for _allobjectsfast instead of a dictionary. Will see how that goes.

@danbudworthmead
Copy link
Contributor Author

Upon further testing, it seems that making _allobjectsfast a concurrent dictionary instead of a regular dictionary seems to have fixed the issue. So it seems as though it was a threading issue all along.

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