-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
Description
Description
mono will crash on struct copy , when struct as method parameter and parent is null.
it seems that mono use mempcy(libc) to copy value of struct without null-check on parent.
Reproduction Steps
The following simple lines of code can reproduce the problem:
using System.Collections.Generic;
public class Program
{
struct BigStruct
{
public long f1;
public long f2;
public long f3;
public long f4;
public object f5;
public object f6;
public object f7;
public long f8;
public long f9;
public long f10;
public long f11;
public long f12;
public long f13;
public long f14;
public long f15;
}
class Holder
{
public BigStruct value;
}
private static void TestCrash(BigStruct bigStruct)
{
System.Console.WriteLine(bigStruct.f1 + bigStruct.f2);
}
public static void Main(string[] args)
{
List<Holder> list = new List<Holder>();
for (int i = 0; i < 10; i++)
{
list.Add(null);
}
foreach (var holder in list)
{
TestCrash(holder.value);
}
}
}
csc Program.cs
mono Program.exe
Expected behavior
It should throw NullReferenceException rather than crash with SegmentFault
Actual behavior
crash on memcpy(libc)
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Reactions are currently unavailable