Skip to content

Commit 50b457a

Browse files
committed
[release/8.0-staging] [mono][jit] Fix passing of byref arguments in mono_gsharedvt_constrained_call (). (#97721)
Fixes #97625.
1 parent b54886b commit 50b457a

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/mono/mono/mini/jit-icalls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,8 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl
14821482
g_assert (fsig->param_count < 16);
14831483
memcpy (new_args, args, fsig->param_count * sizeof (gpointer));
14841484
for (int i = 0; i < fsig->param_count; ++i) {
1485-
if (deref_args [i])
1485+
// If the argument is not a vtype or nullable, deref it
1486+
if (deref_args [i] && (deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_VTYPE && deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_NULLABLE))
14861487
new_args [i] = *(gpointer*)new_args [i];
14871488
}
14881489
args = new_args;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using Xunit;
8+
9+
public static class Runtime_97625
10+
{
11+
public class CustomModel
12+
{
13+
public decimal Cost { get; set; }
14+
}
15+
16+
[Fact]
17+
public static int Test()
18+
{
19+
List<CustomModel> models = new List<CustomModel>();
20+
models.Add(new CustomModel { Cost = 1 });
21+
return models.Average (x => x.Cost) == 1 ? 100 : -1;
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)