Skip to content

Access violation in clrjit.dll on Unsafe.CopyBlockUnaligned with constant 0 copy length #12773

@RossNordby

Description

@RossNordby

On 3.0.0-preview5-27626-15 and 3.0.0-preview6-27728-04 (Windows 10 1809, x64), attempting to run this:

var destination = new byte[1];
var source = new byte[1];
Unsafe.CopyBlockUnaligned(ref destination[0], ref source[0], 0);

results in an access violation in clrjit.dll.

There is no issue if the parameter is not constant, like so:

[MethodImpl(MethodImplOptions.NoInlining)]
public static void Trub(uint copyCount)
{
    var destination = new byte[1];
    var source = new byte[1];
    Unsafe.CopyBlockUnaligned(ref destination[0], ref source[0], copyCount);
}

public static void Test()
{
    Trub(0);
}

Changing the above MethodImpl to AggressiveInlining reintroduces the access violation.

Disabling optimizations avoids the issue. Does not occur on 2.1.11 or 2.2.3.

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions