Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

PagedCharBuffer, Append(string value), never ending loop #5347

@montigab78

Description

@montigab78

In file PagedCharBuffer.cs, method public void Append(string value), the loopwhile (count > 0) at line 56 doed not exit in some scenarios. As a result, the web application hangs.

The problem is that GetCurrentPage and NewPage calls within the loop make use of ArrayPool.RentUse (public abstract T[] Rent(int minimumLength) which takes one parameter, which is the minimumLength. Sometimes the actual length of the returned array is greater than requested one (1024 corresponding to PageSize const). As soon as this happens (apparently when Append argument is a quite long string) any further invokation of GetCurrentPage fails to get new pages.
In fact, if (CurrentPage == null || _charIndex == PageSize returns false as _charIndex is now set to a different value than the expected PageSize (2048 whenever I experienced the bug).
I solved the bug by changing line 59 like this var copyLength = Math.Min(count, PageSize - _charIndex);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions