Skip to content

Commit

Permalink
[release/8.0-staging] [mono][jit] Fix passing of byref arguments in m…
Browse files Browse the repository at this point in the history
…ono_gsharedvt_constrained_call (). (#97721)

Fixes #97625.
  • Loading branch information
vargaz committed Feb 2, 2024
1 parent b54886b commit 50b457a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mono/mono/mini/jit-icalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,8 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl
g_assert (fsig->param_count < 16);
memcpy (new_args, args, fsig->param_count * sizeof (gpointer));
for (int i = 0; i < fsig->param_count; ++i) {
if (deref_args [i])
// If the argument is not a vtype or nullable, deref it
if (deref_args [i] && (deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_VTYPE && deref_args [i] != MONO_GSHAREDVT_BOX_TYPE_NULLABLE))
new_args [i] = *(gpointer*)new_args [i];
}
args = new_args;
Expand Down
23 changes: 23 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_97625/Runtime_97625.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;

public static class Runtime_97625
{
public class CustomModel
{
public decimal Cost { get; set; }
}

[Fact]
public static int Test()
{
List<CustomModel> models = new List<CustomModel>();
models.Add(new CustomModel { Cost = 1 });
return models.Average (x => x.Cost) == 1 ? 100 : -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 50b457a

Please sign in to comment.