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

RecyclableMemoryStream.TryGetBuffer causes infinite loop when UseExponentialLargeBuffer is true #344

Closed
wangzq opened this issue Jun 5, 2024 · 3 comments · Fixed by #345
Assignees
Labels

Comments

@wangzq
Copy link

wangzq commented Jun 5, 2024

Reproduced with 3.0.0

static void Main()
{
	var options = new RecyclableMemoryStreamManager.Options
	{
		UseExponentialLargeBuffer = true,
	};
	var rmsm = new RecyclableMemoryStreamManager(options);
	var size = 1073741825; // this will cause infinite loop in TryGetBuffer below, 1073741824 works.
	var bytes = new byte[size];
	using (var ms = rmsm.GetStream())
	{
		ms.Write(bytes, 0, size);
		ms.TryGetBuffer(out var buffer);
	}
}
@benmwatson
Copy link
Member

Thank you. I have verified the repro in a unit test and I'll take a look at fixing.

@wangzq
Copy link
Author

wangzq commented Jun 7, 2024

@benmwatson thanks for the quick fix! How soon can we expect a new version of the nuget package?

@benmwatson
Copy link
Member

I hope this coming week.

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