-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Dynamic block nodes should not generate non-null assertions #62328
Comments
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsReproduction: using System.Runtime.CompilerServices;
Problem(ref Unsafe.NullRef<byte>(), ref Unsafe.NullRef<byte>(), 0);
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static ref int Problem(ref byte dst, ref byte src, uint count)
{
Unsafe.CopyBlock(ref dst, ref src, count);
return ref Unsafe.As<byte, StructWithIndex>(ref src).Value;
}
struct StructWithIndex
{
public int Index;
public int Value;
} Expected result: NRE. Cause: we make assertion for the GenTreeNode creates assertion:
N002 ( 3, 2) [000011] ---X---N---- * IND struct <l:$1c1, c:$1c0>
In BB01 New Global Constant Assertion: ($81,$0) Value_Number {InitVal($41)} is not 0, index = #01 We cannot make non-null assertions for sources of dynamic block nodes because in the degenerate case of zero-sized copies, the indirection will not be realized. There is language in ECMA 335 saying that this is what is to be expected:
This applies to both source and destination addresses.
|
Of course, a dynamic block is not the only kind of block that can have a size of Note for future readers: #62743 will probably hide this because the RHSs of private static void CpBlkOrder(void** dst, void*[] src, long count)
{
IL.Emit.Ldarg(0);
IL.Emit.Ldind_I();
IL.Emit.Ldarg(1);
IL.Emit.Ldc_I4(0);
IL.Emit.Ldelem_I();
IL.Emit.Ldarg(2);
IL.Emit.Conv_Ovf_U4();
IL.Emit.Volatile();
IL.Emit.Cpblk();
} |
Reproduction:
Expected result: NRE.
Actual result: the program exits normally.
Cause: we make assertion for the
IND struct
node which is the source for the dynamic block copy:We cannot make non-null assertions for addresses of dynamic block nodes because in the degenerate case of zero-sized copies, the indirection will not be realized. There is language in ECMA 335 saying that this is what is to be expected:
This applies to both source and destination addresses.
category:correctness
theme:assertion-prop
The text was updated successfully, but these errors were encountered: