Skip to content

ArgumentNullException ByteBuffer#1021

Merged
FirstGearGames merged 1 commit intoFirstGearGames:mainfrom
IlyaKvant:fix-iterate-outgoing
Mar 17, 2026
Merged

ArgumentNullException ByteBuffer#1021
FirstGearGames merged 1 commit intoFirstGearGames:mainfrom
IlyaKvant:fix-iterate-outgoing

Conversation

@IlyaKvant
Copy link
Copy Markdown
Contributor

Periodically, when one of the client disconnects from the clienthost in the build, this error occurs.

ArgumentNullException: Value cannot be null.
Parameter name: array
System.ArraySegment`1[T]..ctor (T[] array, System.Int32 offset, System.Int32 count) (at <00000000000000000000000000000000>:0)
FishNet.Managing.Transporting.TransportManager.<IterateOutgoing>g__ProcessPacketBundle|69_2 (FishNet.Connection.PacketBundle ppb, System.Boolean isLast, FishNet.Managing.Transporting.TransportManager+<>c__DisplayClass69_0& , FishNet.Managing.Transporting.TransportManager+<>c__DisplayClass69_1& , FishNet.Managing.Transporting.TransportManager+<>c__DisplayClass69_2& ) (at <00000000000000000000000000000000>:0)
FishNet.Managing.Transporting.TransportManager.<IterateOutgoing>g__SendAsServer|69_0 (FishNet.Managing.Transporting.TransportManager+<>c__DisplayClass69_0& ) (at <00000000000000000000000000000000>:0)
FishNet.Managing.Transporting.TransportManager.IterateOutgoing (System.Boolean asServer) (at <00000000000000000000000000000000>:0)
FishNet.Managing.Timing.TimeManager.IncreaseTick () (at <00000000000000000000000000000000>:0)
FishNet.Managing.Timing.TimeManager.TickUpdate () (at <00000000000000000000000000000000>:0)

// Length should always be more than 0 but check to be safe.
if (ppb.GetBuffer(i, out ByteBuffer bb))
{
ArraySegment<byte> segment = new(bb.Data, 0, bb.Length);

ArraySegment<byte> segment = new(bb.Data, 0, bb.Length); // - bb.Data is null

Apparently, when disconnecting, NetworkConnection.ResetState and ByteBuffer.Dispose are called, which sets the Data field to null. However, the HasData flag remains true.

public void Dispose()
{
if (Data != null)
ByteArrayPool.Store(Data);
Data = null;
}

Because of this, the PacketBundle.GetBuffer method returns a buffer that has already been reset to zero, but the further logic breaks down.

bb = _buffers[index];
return bb.HasData;
}

I'm not 100% sure that this fix won't break some other logic, but it's definitely worth paying attention to the incorrect reset of the ByteBuffer state when calling ByteBuffer.Dispose.

@FirstGearGames FirstGearGames merged commit bd5c118 into FirstGearGames:main Mar 17, 2026
FirstGearGames pushed a commit that referenced this pull request Mar 26, 2026
- Fixed NetworkTrigger/Collider incorrectly updating states during replays, resulting in collider Enter callbacks invoking unexpectedly.
- Fixed PredictionRigidbody/2D pending forces conflicting with NetworkTrigger/Collider interactions.
- Fixed Local States not being used as reconcile data when remote states were unavailable.
- Fixed overflow vulnerability with SplitReader.
- Fixed memory allocation attack via packet fragmentation in LiteNetLib (#1026).
- Fixed Buffer ArgumentNullException (#1021).
- Fixed NetworkCollider/Trigger callbacks sometimes invoking OnEnter incorrectly multiple times during a reconcile.
- Fixed cecil errors commonly seen as xyz not imported (#1023).
- Changed (break) NetworkCollider/Trigger now provides Tick as well. Callbacks must be updated to include 'uint tick'.
- Changed reverted objects deinitializing during OnDisable. This change prior caused NulLReferenceExceptions for some when reloading scenes.
- Improved additional sanity checks when an object becomes intialized twice without first deinitializing.
- Added ObserverManager Level of Detail. This feature currently supports prediction reconciles -- improving both server and client performance and bandwidth.
- Added NetworkObject.UseLevelOfDetail.
- Added NetworkObject AddComponentMenu (#1022).
- Added TransportManager.MaximumClientPacketSize.
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

Successfully merging this pull request may close these issues.

2 participants