Skip to content

Random.Next(int,int) can return out-of-bounds result in .NET 6 Preview 2 #50911

@koszeggy

Description

@koszeggy

Description

My UnitTests revealed the following bug when targeting .NET 6 Preview 2:

The Random(int,int) method can return invalid results.

The following example has about 50% chance to return a huge negative value:

int i = new Random().Next(-1, Int32.MaxValue);

Configuration

Reproducible with .NET 6 Preview 2

Other information

The bug is reproducible only if there is no seed specified so the new XoshiroImpl is created internally.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions