Skip to content

NetworkVariable and NetworkList throw NullReferenceException if modified during shutdown #2606

@A1win

Description

@A1win

Description

When Shutdown() is called on the Server and a NetworkObject's OnNetworkDespawn causes a different NetworkObject to modify a NetworkList or NetworkVariable that's attached to it, a NullReferenceException is thrown.

For NetworkList.cs, the exception gets thrown in the MarkNetworkObjectDirty function on line 78.

For NetworkVariableBase.cs, it gets thrown on SetDirty function on line 98.

This didn't happen on NGO version 1.2.0. Could be dependant on script execution order somehow?

Reproduce Steps

  1. Spawn NetworkObject A with a NetworkVariable attached to it.
  2. Spawn NetworkObject B with a NetworkList attached to it.
  3. Spawn NetworkObject C with an OnNetworkDespawn function that modifies the NetworkVariable of NetworkObject A.
  4. Spawn NetworkObject D with an OnNetworkDespawn function that modifies the NetworkList of NetworkObject B.
  5. Shut down the Server. Notice errors thrown by NetworkVariableBase.cs and NetworkList.cs.

I'm not sure if this is a reliable way to reproduce the issue and I don't currently have a small sample project to reproduce it in.

Actual Outcome

NetworkVariableBase and NetworkList cause a NullReferenceException when modified during server shutdown.

Expected Outcome

No exceptions are caused when modifying a NetworkVariable or a NetworkList during server shutdown.

Environment

  • OS: Windows 10
  • Unity Version: 2022.3.4f1
  • Netcode Version: 1.5.1
  • Netcode Commit: 7a969f8

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions