--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+
+// The test returns 2*pointer size struct where the second pointer is a managed object
+// and need a gc reference. On amd64 Unix and arm64 such structs are returned via registers.
+// The was a problem in GCStress infrastracture where it did not mark this pointer alive.
+
+namespace GitHub_23199
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Test1()
+ {
+ ProcessStartInfo pi = new ProcessStartInfo();
+ // pi.Environment calls crossgened HashtableEnumerator::get_Entry returning struct that we need.
+ Console.WriteLine(pi.Environment.Count);
+ }
+
+ struct A
+ {
+ public String a;
+ public String b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static A GetA()
+ {
+ A a = new A();
+ a.a = new String("Hello");
+ a.b = new string("World!");
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void Test2()
+ {
+ A a = GetA();
+ Console.WriteLine(a.a + " " + a.b);
+ }
+
+ static int Main(string[] args)
+ {
+ Test1();
+ Test2();
+ return 100;
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>