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

Negative Length in ReadOnlySequence #57472

Closed
kuda1978 opened this issue Aug 16, 2021 · 2 comments · Fixed by #57479
Closed

Negative Length in ReadOnlySequence #57472

kuda1978 opened this issue Aug 16, 2021 · 2 comments · Fixed by #57479
Assignees
Milestone

Comments

@kuda1978
Copy link

kuda1978 commented Aug 16, 2021

Description

In some cases Length of ReadOnlySequence was Negative.

Test for reproduce problem: ReadOnlySequenceTests.cs

Configuration

.Net SDK: 5.0.400, 6.0.100-preview.7.21379.14

Solution

In file ~\dotnet\runtime\src\libraries\System.Memory\src\System\Buffers\ReadOnlySequence.cs replace folowing string:

public ReadOnlySequence(ReadOnlyMemory<T> memory)
{
    if (MemoryMarshal.TryGetMemoryManager(memory, out MemoryManager<T>? manager, out int index, out int length))
    {
        ...
        _endInteger = index + length;
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Memory untriaged New issue has not been triaged by the area owner labels Aug 16, 2021
@ghost
Copy link

ghost commented Aug 16, 2021

Tagging subscribers to this area: @GrabYourPitchforks, @dotnet/area-system-memory
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

In some cases Length of ReadOnlySequence was Negative.

Test for reproduce problem: ReadOnlySequenceTests.cs

Configuration

.Net SDK: 5.0.400, 6.0.100-preview.7.21379.14

Author: kuda1978
Assignees: -
Labels:

area-System.Memory, untriaged

Milestone: -

@adamsitnik adamsitnik added bug and removed untriaged New issue has not been triaged by the area owner labels Aug 16, 2021
@adamsitnik adamsitnik self-assigned this Aug 16, 2021
@adamsitnik
Copy link
Member

I've confirmed that it's reproducible on 3.1, 5.0 and 6.0 and I am 99.9% sure it's a bug. I am on it.

@adamsitnik adamsitnik added this to the 6.0.0 milestone Aug 16, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 16, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants