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

NRE in 2.0.0 networking code #506

Closed
JustArchi opened this issue Dec 28, 2017 · 6 comments
Closed

NRE in 2.0.0 networking code #506

JustArchi opened this issue Dec 28, 2017 · 6 comments
Labels
Milestone

Comments

@JustArchi
Copy link
Contributor

JustArchi commented Dec 28, 2017

2017-12-28 16:44:42|dotnet-9599|FATAL|ASF|OnUnhandledException() System.NullReferenceException: Object reference not set to an instance of an object.
at SteamKit2.Internal.CMClient.Disconnected(Object sender, DisconnectedEventArgs e)
at SteamKit2.TcpConnection.Release(Boolean userRequestedDisconnect)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 

This was reproduced on SK 2.0.0 (latest/final). I'm trying to get more details about this one in the meantime, since stacktrace is everything I have for now.

Thank you in advance and happy new year 🎉

@JustArchi JustArchi changed the title NRE in networking code NRE in 2.0.0 networking code Dec 28, 2017
@azuisleet
Copy link
Member

azuisleet commented Dec 30, 2017

I believe this is a result of two competing Disconnected calls: for example an explicit Connect or Disconnect and a concurrent connection termination. I've locked the section around connection in Disconnected in e681328.

This assumes that EventHandlers can't block eg by having an ExecutionContext (or is it SynchronizationContext?) associated that would try to dispatch Disconnected on another thread while blocking a Disconnect call. I need to figure out if this is indeed possible.

@azuisleet
Copy link
Member

Revised in 14d883b as a deadlock would have been possible when Disconnect holds connectionLock, waits for the setup task, and the setup task tries to call Disconnected.

@JustArchi
Copy link
Contributor Author

JustArchi commented Dec 30, 2017

I believe this is a result of two competing Disconnected calls: for example an explicit Connect or Disconnect and a concurrent connection termination.

This is very likely the case, I got some extra details in the meantime.

2017-12-29 12:54:45|dotnet-1206|INFO|nicobesser|OnLoggedOff() Logged off of Steam: LoggedInElsewhere
2017-12-29 12:54:45|dotnet-1206|INFO|nicobesser|OnDisconnected() Disconnected from Steam!
2017-12-29 12:54:45|dotnet-1206|INFO|nicobesser|OnDisconnected() Reconnecting...
2017-12-29 12:54:45|dotnet-1206|INFO|nicobesser|Connect() Connecting...
2017-12-29 12:54:45|dotnet-1206|FATAL|ASF|OnUnhandledException() System.NullReferenceException: Object reference not set to an instance of an object.
   at SteamKit2.Internal.CMClient.Disconnected(Object sender, DisconnectedEventArgs e)
   at SteamKit2.TcpConnection.Release(Boolean userRequestedDisconnect)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

My program simply tries to reconnect the moment it receives DisconnectedCallback. If it's possible that at that moment some connection leftovers are still pending to cleanup, it's very likely the culprit.

@yaakov-h yaakov-h added this to the 2.1.0 milestone Dec 30, 2017
@yaakov-h yaakov-h added the bug label Dec 30, 2017
@yaakov-h
Copy link
Member

Anything still to be done here, or is this closable?

@JustArchi
Copy link
Contributor Author

JustArchi commented Jan 4, 2018

Any chance we can get SK2 2.0.1 or 2.1.0-alpha shipped with this fix? I'd love to further test if anything new pops up, and if the issue is fixed, thanks! ❤️

@azuisleet
Copy link
Member

I believe this is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants