From 60fcdfbf1c1f7d3b6f21a0258dee9035bef5b788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 15 Jan 2025 11:01:25 +0100 Subject: [PATCH 01/20] Fix wrong alias-to for tvos AOT packs in net8 workload manifest (#110871) --- .../WorkloadManifest.json.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.net8.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.net8.Manifest/WorkloadManifest.json.in index 5fd792e7048ab4..3c3e63c3ae584c 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.net8.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.net8.Manifest/WorkloadManifest.json.in @@ -277,7 +277,7 @@ "kind": "framework", "version": "${PackageVersionNet8}", "alias-to": { - "any": "Microsoft.NETCore.App.Runtime.Mono.osx-arm64" + "any": "Microsoft.NETCore.App.Runtime.osx-arm64" } }, "Microsoft.NETCore.App.Runtime.net8.osx-x64": { @@ -312,8 +312,8 @@ "kind": "Sdk", "version": "${PackageVersionNet8}", "alias-to": { - "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.tvos-arm64", - "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.tvos-arm64" + "osx-x64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.tvos-arm64", + "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.tvos-arm64" } }, "Microsoft.NETCore.App.Runtime.Mono.net8.tvos-arm64" : { From 114532f7ea6e7766bc5ffc43e011ff66432900d4 Mon Sep 17 00:00:00 2001 From: Radek Zikmund <32671551+rzikm@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:52:05 +0100 Subject: [PATCH 02/20] [release/9.0] Disable tests targetting http://corefx-net-http11.azurewebsites.net (#111402) * Disable more tests dependent on http://corefx-net-http11.azurewebsites.net (#111354) * Disable more tests dependent on http://corefx-net-http11.azurewebsites.net * Disable winhttphandlertests * Disable tests using http://corefx-net-http11.azurewebsites.net (#111235) Disabling until HTTPS redirection can be turned off at the server. --- .../tests/System/Net/Configuration.Http.cs | 39 ++++++++++++++++--- .../System/Net/Configuration.WebSockets.cs | 13 +++++-- .../HttpClientHandlerTest.RemoteServer.cs | 21 +++++----- ...ttpClientHandlerTest.ServerCertificates.cs | 1 + .../FunctionalTests/ServerCertificateTest.cs | 1 + .../FunctionalTests/WinHttpHandlerTest.cs | 2 +- .../tests/FunctionalTests/MetricsTest.cs | 4 +- 7 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Configuration.Http.cs b/src/libraries/Common/tests/System/Net/Configuration.Http.cs index f568e54f261d22..f7e6fc759c0dd5 100644 --- a/src/libraries/Common/tests/System/Net/Configuration.Http.cs +++ b/src/libraries/Common/tests/System/Net/Configuration.Http.cs @@ -64,9 +64,16 @@ public static Uri[] GetEchoServerList() if (PlatformDetection.IsFirefox) { // https://github.com/dotnet/runtime/issues/101115 - return [RemoteEchoServer]; + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // return [RemoteEchoServer]; + return []; } - return [RemoteEchoServer, SecureRemoteEchoServer, Http2RemoteEchoServer]; + return [ + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // RemoteEchoServer, + SecureRemoteEchoServer, + Http2RemoteEchoServer + ]; } public static readonly Uri RemoteVerifyUploadServer = new Uri("http://" + Host + "/" + VerifyUploadHandler); @@ -82,8 +89,20 @@ public static Uri[] GetEchoServerList() public static Uri RemoteLoopServer => new Uri("ws://" + RemoteLoopHost + "/" + RemoteLoopHandler); public static readonly object[][] EchoServers = GetEchoServerList().Select(x => new object[] { x }).ToArray(); - public static readonly object[][] VerifyUploadServers = { new object[] { RemoteVerifyUploadServer }, new object[] { SecureRemoteVerifyUploadServer }, new object[] { Http2RemoteVerifyUploadServer } }; - public static readonly object[][] CompressedServers = { new object[] { RemoteDeflateServer }, new object[] { RemoteGZipServer }, new object[] { Http2RemoteDeflateServer }, new object[] { Http2RemoteGZipServer } }; + public static readonly object[][] VerifyUploadServers = { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteVerifyUploadServer }, + new object[] { SecureRemoteVerifyUploadServer }, + new object[] { Http2RemoteVerifyUploadServer } + }; + + public static readonly object[][] CompressedServers = { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteDeflateServer }, + new object[] { RemoteGZipServer }, + new object[] { Http2RemoteDeflateServer }, + new object[] { Http2RemoteGZipServer } + }; public static readonly object[][] Http2Servers = { new object[] { new Uri("https://" + Http2Host) } }; public static readonly object[][] Http2NoPushServers = { new object[] { new Uri("https://" + Http2NoPushHost) } }; @@ -97,9 +116,17 @@ public static IEnumerable GetRemoteServers() if (PlatformDetection.IsFirefox) { // https://github.com/dotnet/runtime/issues/101115 - return new RemoteServer[] { RemoteHttp11Server }; + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // return new RemoteServer[] { RemoteHttp11Server }; + return []; } - return new RemoteServer[] { RemoteHttp11Server, RemoteSecureHttp11Server, RemoteHttp2Server }; + return new RemoteServer[] + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // RemoteHttp11Server, + RemoteSecureHttp11Server, + RemoteHttp2Server + }; } public static readonly IEnumerable RemoteServersMemberData = GetRemoteServers().Select(s => new object[] { s }); diff --git a/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs b/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs index c5686be67b4ef9..d0f1eab545177e 100644 --- a/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs +++ b/src/libraries/Common/tests/System/Net/Configuration.WebSockets.cs @@ -28,11 +28,14 @@ public static object[][] GetEchoServers() { // https://github.com/dotnet/runtime/issues/101115 return new object[][] { - new object[] { RemoteEchoServer }, + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteEchoServer }, + }; } return new object[][] { - new object[] { RemoteEchoServer }, + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteEchoServer }, new object[] { SecureRemoteEchoServer }, }; } @@ -43,11 +46,13 @@ public static object[][] GetEchoHeadersServers() { // https://github.com/dotnet/runtime/issues/101115 return new object[][] { - new object[] { RemoteEchoHeadersServer }, + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteEchoHeadersServer }, }; } return new object[][] { - new object[] { RemoteEchoHeadersServer }, + // [ActiveIssue("https://github.com/dotnet/runtime/issues/110578)] + // new object[] { RemoteEchoHeadersServer }, new object[] { SecureRemoteEchoHeadersServer }, }; } diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs index dd9db9bbe1f087..04cfc593343f85 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs @@ -70,7 +70,7 @@ public async Task UseDefaultCredentials_SetToFalseAndServerNeedsAuth_StatusCodeU handler.UseDefaultCredentials = false; using (HttpClient client = CreateHttpClient(handler)) { - Uri uri = Configuration.Http.RemoteHttp11Server.NegotiateAuthUriForDefaultCreds; + Uri uri = Configuration.Http.RemoteSecureHttp11Server.NegotiateAuthUriForDefaultCreds; _output.WriteLine("Uri: {0}", uri); using (HttpResponseMessage response = await client.GetAsync(uri)) { @@ -601,9 +601,9 @@ public async Task PostAsync_CallMethod_EmptyContent(Configuration.Http.RemoteSer public static IEnumerable ExpectContinueVersion() { return - from expect in new bool?[] {true, false, null} - from version in new Version[] {new Version(1, 0), new Version(1, 1), new Version(2, 0)} - select new object[] {expect, version}; + from expect in new bool?[] { true, false, null } + from version in new Version[] { new Version(1, 0), new Version(1, 1), new Version(2, 0) } + select new object[] { expect, version }; } [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] @@ -775,7 +775,8 @@ public async Task SendAsync_SendRequestUsingMethodToEchoServerWithNoContent_Meth { var request = new HttpRequestMessage( new HttpMethod(method), - serverUri) { Version = UseVersion }; + serverUri) + { Version = UseVersion }; using (HttpResponseMessage response = await client.SendAsync(TestAsync, request)) { @@ -801,7 +802,8 @@ public async Task SendAsync_SendRequestUsingMethodToEchoServerWithContent_Succes { var request = new HttpRequestMessage( new HttpMethod(method), - serverUri) { Version = UseVersion }; + serverUri) + { Version = UseVersion }; request.Content = new StringContent(ExpectedContent); using (HttpResponseMessage response = await client.SendAsync(TestAsync, request)) { @@ -980,6 +982,7 @@ public async Task GetAsync_AllowAutoRedirectTrue_RedirectFromHttpToHttp_StatusCo [OuterLoop("Uses external servers")] [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/55083", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/110578")] public async Task GetAsync_AllowAutoRedirectTrue_RedirectFromHttpToHttps_StatusCodeOK() { HttpClientHandler handler = CreateHttpClientHandler(); @@ -1064,9 +1067,9 @@ public async Task GetAsync_MaxAutomaticRedirectionsNServerHops_ThrowsIfTooMany(i handler.MaxAutomaticRedirections = maxHops; using (HttpClient client = CreateHttpClient(handler)) { - Task t = client.GetAsync(Configuration.Http.RemoteHttp11Server.RedirectUriForDestinationUri( + Task t = client.GetAsync(Configuration.Http.RemoteSecureHttp11Server.RedirectUriForDestinationUri( statusCode: 302, - destinationUri: Configuration.Http.RemoteHttp11Server.EchoUri, + destinationUri: Configuration.Http.RemoteSecureHttp11Server.EchoUri, hops: hops)); if (hops <= maxHops) @@ -1074,7 +1077,7 @@ public async Task GetAsync_MaxAutomaticRedirectionsNServerHops_ThrowsIfTooMany(i using (HttpResponseMessage response = await t) { Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal(Configuration.Http.RemoteEchoServer, response.RequestMessage.RequestUri); + Assert.Equal(Configuration.Http.SecureRemoteEchoServer, response.RequestMessage.RequestUri); } } else diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs index 4dc2eb3fcfdeaf..95ba0752a5daa4 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs @@ -97,6 +97,7 @@ public async Task NoCallback_ValidCertificate_SuccessAndExpectedPropertyBehavior [OuterLoop("Uses external servers")] [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/110578")] public async Task UseCallback_NotSecureConnection_CallbackNotCalled() { HttpClientHandler handler = CreateHttpClientHandler(); diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ServerCertificateTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ServerCertificateTest.cs index df73619bf8dad8..4f7d573df68b09 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ServerCertificateTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ServerCertificateTest.cs @@ -32,6 +32,7 @@ public async Task NoCallback_ValidCertificate_CallbackNotCalled() [OuterLoop] [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/110578")] public async Task UseCallback_NotSecureConnection_CallbackNotCalled() { var handler = new WinHttpHandler(); diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs index 0abe14c11887bf..cc2b97bdde6da7 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs @@ -55,7 +55,7 @@ public async Task GetAsync_RedirectResponseHasCookie_CookieSentToFinalUri( string cookieName, string cookieValue) { - Uri uri = System.Net.Test.Common.Configuration.Http.RemoteHttp11Server.RedirectUriForDestinationUri(302, System.Net.Test.Common.Configuration.Http.RemoteEchoServer, 1); + Uri uri = System.Net.Test.Common.Configuration.Http.RemoteSecureHttp11Server.RedirectUriForDestinationUri(302, System.Net.Test.Common.Configuration.Http.SecureRemoteEchoServer, 1); var handler = new WinHttpHandler(); handler.WindowsProxyUsePolicy = WindowsProxyUsePolicy.UseWinInetProxy; handler.CookieUsePolicy = cookieUsePolicy; diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs index cb8a2b7c833556..473be2724c65da 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs @@ -381,7 +381,7 @@ public async Task ExternalServer_DurationMetrics_Recorded() using InstrumentRecorder openConnectionsRecorder = SetupInstrumentRecorder(InstrumentNames.OpenConnections); Uri uri = UseVersion == HttpVersion.Version11 - ? Test.Common.Configuration.Http.RemoteHttp11Server.EchoUri + ? Test.Common.Configuration.Http.RemoteSecureHttp11Server.EchoUri : Test.Common.Configuration.Http.RemoteHttp2Server.EchoUri; IPAddress[] addresses = await Dns.GetHostAddressesAsync(uri.Host); addresses = addresses.Union(addresses.Select(a => a.MapToIPv6())).ToArray(); @@ -1259,7 +1259,7 @@ public Task RequestDuration_Redirect_RecordedForEachHttpSpan() }); }, options: new GenericLoopbackOptions() { UseSsl = true }); - }, options: new GenericLoopbackOptions() { UseSsl = false}); + }, options: new GenericLoopbackOptions() { UseSsl = false }); } [Fact] From e781fb7b02a217add8faa8c528cb7f4edddc8bc3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:26:05 -0600 Subject: [PATCH 03/20] [release/9.0-staging] Support generic fields in PersistedAssemblyBuilder (#110839) --- .../Reflection/Emit/ModuleBuilderImpl.cs | 15 ++-- .../AssemblySaveTypeBuilderTests.cs | 89 ++++++++++++++++++- 2 files changed, 95 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs index bbd52a5b7a0dfa..2ead8405732022 100644 --- a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs +++ b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs @@ -734,13 +734,16 @@ private EntityHandle GetMemberReferenceHandle(MemberInfo memberInfo) { case FieldInfo field: Type declaringType = field.DeclaringType!; - if (field.DeclaringType!.IsGenericTypeDefinition) + if (declaringType.IsGenericTypeDefinition) { //The type of the field has to be fully instantiated type. declaringType = declaringType.MakeGenericType(declaringType.GetGenericArguments()); } + + Type fieldType = ((FieldInfo)GetOriginalMemberIfConstructedType(field)).FieldType; memberHandle = AddMemberReference(field.Name, GetTypeHandle(declaringType), - MetadataSignatureHelper.GetFieldSignature(field.FieldType, field.GetRequiredCustomModifiers(), field.GetOptionalCustomModifiers(), this)); + MetadataSignatureHelper.GetFieldSignature(fieldType, field.GetRequiredCustomModifiers(), field.GetOptionalCustomModifiers(), this)); + break; case ConstructorInfo ctor: ctor = (ConstructorInfo)GetOriginalMemberIfConstructedType(ctor); @@ -809,17 +812,17 @@ internal static SignatureCallingConvention GetSignatureConvention(CallingConvent return convention; } - private MemberInfo GetOriginalMemberIfConstructedType(MethodBase methodBase) + private MemberInfo GetOriginalMemberIfConstructedType(MemberInfo memberInfo) { - Type declaringType = methodBase.DeclaringType!; + Type declaringType = memberInfo.DeclaringType!; if (declaringType.IsConstructedGenericType && declaringType.GetGenericTypeDefinition() is not TypeBuilderImpl && !ContainsTypeBuilder(declaringType.GetGenericArguments())) { - return declaringType.GetGenericTypeDefinition().GetMemberWithSameMetadataDefinitionAs(methodBase); + return declaringType.GetGenericTypeDefinition().GetMemberWithSameMetadataDefinitionAs(memberInfo); } - return methodBase; + return memberInfo; } private static Type[] ParameterTypes(ParameterInfo[] parameterInfos) diff --git a/src/libraries/System.Reflection.Emit/tests/PersistedAssemblyBuilder/AssemblySaveTypeBuilderTests.cs b/src/libraries/System.Reflection.Emit/tests/PersistedAssemblyBuilder/AssemblySaveTypeBuilderTests.cs index 31536bc266c0a1..f508da07364f26 100644 --- a/src/libraries/System.Reflection.Emit/tests/PersistedAssemblyBuilder/AssemblySaveTypeBuilderTests.cs +++ b/src/libraries/System.Reflection.Emit/tests/PersistedAssemblyBuilder/AssemblySaveTypeBuilderTests.cs @@ -5,6 +5,8 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; using Xunit; namespace System.Reflection.Emit.Tests @@ -124,11 +126,15 @@ public void CreateMembersThatUsesTypeLoadedFromCoreAssemblyTest() } } - private static TypeBuilder CreateAssemblyAndDefineType(out PersistedAssemblyBuilder assemblyBuilder) + private static ModuleBuilder CreateAssembly(out PersistedAssemblyBuilder assemblyBuilder) { assemblyBuilder = AssemblySaveTools.PopulateAssemblyBuilder(s_assemblyName); - return assemblyBuilder.DefineDynamicModule("MyModule") - .DefineType("TestInterface", TypeAttributes.Interface | TypeAttributes.Abstract); + return assemblyBuilder.DefineDynamicModule("MyModule"); + } + + private static TypeBuilder CreateAssemblyAndDefineType(out PersistedAssemblyBuilder assemblyBuilder) + { + return CreateAssembly(out assemblyBuilder).DefineType("TestInterface", TypeAttributes.Interface | TypeAttributes.Abstract); } [Fact] @@ -205,6 +211,83 @@ public void SaveGenericTypeParametersForAType(string[] typeParamNames) } } + private class GenericClassWithGenericField + { +#pragma warning disable CS0649 + public T F; +#pragma warning restore CS0649 + } + + private class GenericClassWithNonGenericField + { +#pragma warning disable CS0649 + public int F; +#pragma warning restore CS0649 + } + + public static IEnumerable GenericTypesWithField() + { + yield return new object[] { typeof(GenericClassWithGenericField), true }; + yield return new object[] { typeof(GenericClassWithNonGenericField), false }; + } + + [Theory] + [MemberData(nameof(GenericTypesWithField))] + public void SaveGenericField(Type declaringType, bool shouldFieldBeGeneric) + { + using (TempFile file = TempFile.Create()) + { + ModuleBuilder mb = CreateAssembly(out PersistedAssemblyBuilder assemblyBuilder); + TypeBuilder tb = mb.DefineType("C", TypeAttributes.Class); + MethodBuilder method = tb.DefineMethod("TestMethod", MethodAttributes.Public, returnType: typeof(int), parameterTypes: null); + ILGenerator il = method.GetILGenerator(); + il.Emit(OpCodes.Newobj, declaringType.GetConstructor([])); + il.Emit(OpCodes.Ldfld, declaringType.GetField("F")); + il.Emit(OpCodes.Ret); + Type createdType = tb.CreateType(); + assemblyBuilder.Save(file.Path); + + using (FileStream stream = File.OpenRead(file.Path)) + { + using (PEReader peReader = new PEReader(stream)) + { + bool found = false; + MetadataReader metadataReader = peReader.GetMetadataReader(); + foreach (MemberReferenceHandle memberRefHandle in metadataReader.MemberReferences) + { + MemberReference memberRef = metadataReader.GetMemberReference(memberRefHandle); + if (memberRef.GetKind() == MemberReferenceKind.Field) + { + Assert.False(found); + found = true; + + Assert.Equal("F", metadataReader.GetString(memberRef.Name)); + + // A reference to a generic field should point to the open generic field, and not the resolved generic type. + Assert.Equal(shouldFieldBeGeneric, IsGenericField(metadataReader.GetBlobReader(memberRef.Signature))); + } + } + + Assert.True(found); + } + } + } + + static bool IsGenericField(BlobReader signatureReader) + { + while (signatureReader.RemainingBytes > 0) + { + SignatureTypeCode typeCode = signatureReader.ReadSignatureTypeCode(); + if (typeCode == SignatureTypeCode.GenericTypeParameter) + { + return true; + } + } + + return false; + } + } + private static void SetVariousGenericParameterValues(GenericTypeParameterBuilder[] typeParams) { typeParams[0].SetInterfaceConstraints([typeof(IAccess), typeof(INoMethod)]); From f2a1313892e0867edaca544482013ea2d9a73dfb Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 16 Jan 2025 13:54:14 +0100 Subject: [PATCH 04/20] Re-enable skiasharp WBT tests (#109232) (#110734) * [wasm] Re-enable skiasharp WBT tests * Disable Debug/AOT combination That would trigger build error, because we don't support that combination anymore --- src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs | 1 - src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs | 4 ++-- src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs index 25bd5c7f4d06bf..c93ec2c6af452f 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs @@ -22,7 +22,6 @@ public MiscTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildC [InlineData("Debug", false)] [InlineData("Release", true)] [InlineData("Release", false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/103566")] public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRelink) { string id = $"blz_deploy_on_build_{config}_{nativeRelink}_{GetRandomId()}"; diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs index 3dc64bc556d538..cccc44efb621ee 100644 --- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs @@ -605,8 +605,8 @@ internal BuildPaths GetBuildPaths(BuildArgs buildArgs, bool forPublish = true) } protected static string GetSkiaSharpReferenceItems() - => @" - + => @" + "; protected static string s_mainReturns42 = @" diff --git a/src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs b/src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs index 8444f54308d5b9..990d331f0c580c 100644 --- a/src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs @@ -50,8 +50,7 @@ public void ProjectWithNativeReference(BuildArgs buildArgs, RunHost host, string [Theory] [BuildAndRun(aot: false)] - [BuildAndRun(aot: true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/103566")] + [BuildAndRun(aot: true, config: "Release")] public void ProjectUsingSkiaSharp(BuildArgs buildArgs, RunHost host, string id) { string projectName = $"AppUsingSkiaSharp"; From f9ffbe08845d0fe93d95cbcaa133dc5ca77015b9 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Fri, 17 Jan 2025 01:10:21 +0100 Subject: [PATCH 05/20] [release/9.0-staging] Backport test fixes related to BinaryFormatter removal (#111508) * [NRBF] Reduce the most time-consuming test case to avoid timeouts for checked builds (#110550) * don't run drawing tests on Mono (#111208) * don't run Drawing-related tests that do things like creating Bitmaps on Mono, as it's not supported (it does not support ComWrappers) * re-enable the tests --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 4 ++-- .../tests/ArraySinglePrimitiveRecordTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 67cde84c48389b..29118142d279fa 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -168,8 +168,8 @@ private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly() return !(bool)typeof(LambdaExpression).GetMethod("get_CanCompileToIL").Invoke(null, Array.Empty()); } - // Drawing is not supported on non windows platforms in .NET 7.0+. - public static bool IsDrawingSupported => IsWindows && IsNotWindowsNanoServer && IsNotWindowsServerCore; + // Drawing is not supported on non windows platforms in .NET 7.0+ and on Mono. + public static bool IsDrawingSupported => IsWindows && IsNotWindowsNanoServer && IsNotWindowsServerCore && IsNotMonoRuntime; public static bool IsAsyncFileIOSupported => !IsBrowser && !IsWasi; diff --git a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs index 49d523088a89fe..bea83b27211f80 100644 --- a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs +++ b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs @@ -19,7 +19,7 @@ public NonSeekableStream(byte[] buffer) : base(buffer) { } public static IEnumerable GetCanReadArrayOfAnySizeArgs() { - foreach (int size in new[] { 1, 127, 128, 512_001, 512_001 }) + foreach (int size in new[] { 1, 127, 128, 20_001 }) { yield return new object[] { size, true }; yield return new object[] { size, false }; From 9efd46e3dea337387364cf71007fe758b6144192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 21 Jan 2025 12:55:46 +0100 Subject: [PATCH 06/20] [release/9.0] [wasi] Disable build in .NET 9 (#108877) --- eng/pipelines/runtime.yml | 38 +++++++++---------- .../scenarios/BuildWasiAppsJobsList.txt | 7 ---- .../WorkloadManifest.Wasi.targets.in | 4 ++ 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index bcab359dde5792..f06667f3e8e6e2 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -926,25 +926,25 @@ extends: # WASI/WASM - - template: /eng/pipelines/common/templates/wasm-library-tests.yml - parameters: - platforms: - - wasi_wasm - - wasi_wasm_win - nameSuffix: '_Smoke' - extraBuildArgs: /p:EnableAggressiveTrimming=true /p:RunWasmSamples=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) - shouldRunSmokeOnly: true - alwaysRun: ${{ variables.isRollingBuild }} - scenarios: - - WasmTestOnWasmtime - - - template: /eng/pipelines/common/templates/simple-wasm-build-tests.yml - parameters: - platforms: - - wasi_wasm - - wasi_wasm_win - extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) - alwaysRun: ${{ variables.isRollingBuild }} + # - template: /eng/pipelines/common/templates/wasm-library-tests.yml + # parameters: + # platforms: + # - wasi_wasm + # - wasi_wasm_win + # nameSuffix: '_Smoke' + # extraBuildArgs: /p:EnableAggressiveTrimming=true /p:RunWasmSamples=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + # shouldRunSmokeOnly: true + # alwaysRun: ${{ variables.isRollingBuild }} + # scenarios: + # - WasmTestOnWasmtime + + # - template: /eng/pipelines/common/templates/simple-wasm-build-tests.yml + # parameters: + # platforms: + # - wasi_wasm + # - wasi_wasm_win + # extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + # alwaysRun: ${{ variables.isRollingBuild }} # # Android devices diff --git a/eng/testing/scenarios/BuildWasiAppsJobsList.txt b/eng/testing/scenarios/BuildWasiAppsJobsList.txt index 86c0517585a480..e69de29bb2d1d6 100644 --- a/eng/testing/scenarios/BuildWasiAppsJobsList.txt +++ b/eng/testing/scenarios/BuildWasiAppsJobsList.txt @@ -1,7 +0,0 @@ -Wasi.Build.Tests.InvariantTests -Wasi.Build.Tests.ILStripTests -Wasi.Build.Tests.SdkMissingTests -Wasi.Build.Tests.RuntimeConfigTests -Wasi.Build.Tests.WasiTemplateTests -Wasi.Build.Tests.PInvokeTableGeneratorTests -Wasi.Build.Tests.WasiLibraryModeTests diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.Wasi.targets.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.Wasi.targets.in index e0b7323d6bcee2..07477c653a68a2 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.Wasi.targets.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.Wasi.targets.in @@ -9,4 +9,8 @@ $(WasiNativeWorkloadAvailable) + + + + From 0b717883a7116e9acb8cbb86bf2b5d429de218a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:28:00 +0100 Subject: [PATCH 07/20] [mono] Disable UnitTest_GVM_TypeLoadException on fullAOT (#111394) Co-authored-by: Matous Kozak --- src/tests/issues.targets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 7a2cff6628af3a..e03e2fe28bd388 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -2464,6 +2464,10 @@ Reflection.Emit is not supported on fullaot + + + Attempting to JIT compile method 'void CMain:RunInvalidTest1 ()' while running in aot-only mode. + From eaea271c48894aee91b8aaae1e553c15df620e52 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Thu, 23 Jan 2025 17:17:26 -0800 Subject: [PATCH 08/20] Fix `UnsafeAccessor` scenario for modopts/modreqs when comparing field sigs. (#111648) (#111675) * Consume custom modifiers and ByRef in RetType signature prior to comparing field signature. --- src/coreclr/vm/prestub.cpp | 11 +++- src/coreclr/vm/siginfo.cpp | 2 +- src/coreclr/vm/siginfo.hpp | 8 +++ .../UnsafeAccessors/UnsafeAccessorsTests.cs | 64 +++++++++++++++---- 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index e494c74667cba1..99086a462a26fb 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -1445,11 +1445,18 @@ namespace DWORD declArgCount; IfFailThrow(CorSigUncompressData_EndPtr(pSig1, pEndSig1, &declArgCount)); + if (pSig1 >= pEndSig1) + ThrowHR(META_E_BAD_SIGNATURE); - // UnsafeAccessors for fields require return types be byref. - // This was explicitly checked in TryGenerateUnsafeAccessor(). + // UnsafeAccessors for fields require return types be byref. However, we first need to + // consume any custom modifiers which are prior to the expected ELEMENT_TYPE_BYREF in + // the RetType signature (II.23.2.11). + _ASSERTE(state.IgnoreCustomModifiers); // We should always ignore custom modifiers for field look-up. + MetaSig::ConsumeCustomModifiers(pSig1, pEndSig1); if (pSig1 >= pEndSig1) ThrowHR(META_E_BAD_SIGNATURE); + + // The ELEMENT_TYPE_BYREF was explicitly checked in TryGenerateUnsafeAccessor(). CorElementType byRefType = CorSigUncompressElementType(pSig1); _ASSERTE(byRefType == ELEMENT_TYPE_BYREF); diff --git a/src/coreclr/vm/siginfo.cpp b/src/coreclr/vm/siginfo.cpp index facb809cd4841a..2b50fdfcfeaa49 100644 --- a/src/coreclr/vm/siginfo.cpp +++ b/src/coreclr/vm/siginfo.cpp @@ -3604,7 +3604,7 @@ BOOL CompareTypeTokens(mdToken tk1, mdToken tk2, ModuleBase *pModule1, ModuleBas #endif //!DACCESS_COMPILE } // CompareTypeTokens -static void ConsumeCustomModifiers(PCCOR_SIGNATURE& pSig, PCCOR_SIGNATURE pEndSig) +void MetaSig::ConsumeCustomModifiers(PCCOR_SIGNATURE& pSig, PCCOR_SIGNATURE pEndSig) { mdToken tk; CorElementType type; diff --git a/src/coreclr/vm/siginfo.hpp b/src/coreclr/vm/siginfo.hpp index fab9a79260d2d1..49f14b57c34bee 100644 --- a/src/coreclr/vm/siginfo.hpp +++ b/src/coreclr/vm/siginfo.hpp @@ -945,6 +945,14 @@ class MetaSig //------------------------------------------------------------------ CorElementType GetByRefType(TypeHandle* pTy) const; + //------------------------------------------------------------------ + // Consume the custom modifiers, if any, in the current signature + // and update it. + // This is a non destructive operation if the current signature is not + // pointing at a sequence of ELEMENT_TYPE_CMOD_REQD or ELEMENT_TYPE_CMOD_OPT. + //------------------------------------------------------------------ + static void ConsumeCustomModifiers(PCCOR_SIGNATURE& pSig, PCCOR_SIGNATURE pEndSig); + // Struct used to capture in/out state during the comparison // of element types. struct CompareState diff --git a/src/tests/baseservices/compilerservices/UnsafeAccessors/UnsafeAccessorsTests.cs b/src/tests/baseservices/compilerservices/UnsafeAccessors/UnsafeAccessorsTests.cs index f4efeacf80fe94..fcdb479c1a6353 100644 --- a/src/tests/baseservices/compilerservices/UnsafeAccessors/UnsafeAccessorsTests.cs +++ b/src/tests/baseservices/compilerservices/UnsafeAccessors/UnsafeAccessorsTests.cs @@ -328,28 +328,70 @@ public static void Verify_AccessAllFields_CorElementType() extern static ref delegate* GetFPtr(ref AllFields f); } - // Contains fields that have modopts/modreqs - struct FieldsWithModifiers + // Contains fields that are volatile + struct VolatileFields { private static volatile int s_vInt; private volatile int _vInt; } + // Accessors for fields that are volatile + static class AccessorsVolatile + { + [UnsafeAccessor(UnsafeAccessorKind.StaticField, Name="s_vInt")] + public extern static ref int GetStaticVolatileInt(ref VolatileFields f); + + [UnsafeAccessor(UnsafeAccessorKind.Field, Name="_vInt")] + public extern static ref int GetVolatileInt(ref VolatileFields f); + } + [Fact] - public static void Verify_AccessFieldsWithModifiers() + public static void Verify_AccessFieldsWithVolatile() { - Console.WriteLine($"Running {nameof(Verify_AccessFieldsWithModifiers)}"); + Console.WriteLine($"Running {nameof(Verify_AccessFieldsWithVolatile)}"); - FieldsWithModifiers fieldsWithModifiers = default; + VolatileFields fieldsWithVolatile = default; - GetStaticVolatileInt(ref fieldsWithModifiers) = default; - GetVolatileInt(ref fieldsWithModifiers) = default; + AccessorsVolatile.GetStaticVolatileInt(ref fieldsWithVolatile) = default; + AccessorsVolatile.GetVolatileInt(ref fieldsWithVolatile) = default; + } - [UnsafeAccessor(UnsafeAccessorKind.StaticField, Name="s_vInt")] - extern static ref int GetStaticVolatileInt(ref FieldsWithModifiers f); + // Contains fields that are readonly + readonly struct ReadOnlyFields + { + public static readonly int s_rInt; + public readonly int _rInt; + } - [UnsafeAccessor(UnsafeAccessorKind.Field, Name="_vInt")] - extern static ref int GetVolatileInt(ref FieldsWithModifiers f); + // Accessors for fields that are readonly + static class AccessorsReadOnly + { + [UnsafeAccessor(UnsafeAccessorKind.StaticField, Name="s_rInt")] + public extern static ref readonly int GetStaticReadOnlyInt(ref readonly ReadOnlyFields f); + + [UnsafeAccessor(UnsafeAccessorKind.Field, Name="_rInt")] + public extern static ref readonly int GetReadOnlyInt(ref readonly ReadOnlyFields f); + } + + [Fact] + public static void Verify_AccessFieldsWithReadOnlyRefs() + { + Console.WriteLine($"Running {nameof(Verify_AccessFieldsWithReadOnlyRefs)}"); + + ReadOnlyFields readOnlyFields = default; + + Assert.True(Unsafe.AreSame(in AccessorsReadOnly.GetStaticReadOnlyInt(in readOnlyFields), in ReadOnlyFields.s_rInt)); + Assert.True(Unsafe.AreSame(in AccessorsReadOnly.GetReadOnlyInt(in readOnlyFields), in readOnlyFields._rInt)); + + // Test the local declaration of the signature since it places modopts/modreqs differently. + Assert.True(Unsafe.AreSame(in GetStaticReadOnlyIntLocal(in readOnlyFields), in ReadOnlyFields.s_rInt)); + Assert.True(Unsafe.AreSame(in GetReadOnlyIntLocal(in readOnlyFields), in readOnlyFields._rInt)); + + [UnsafeAccessor(UnsafeAccessorKind.StaticField, Name="s_rInt")] + extern static ref readonly int GetStaticReadOnlyIntLocal(ref readonly ReadOnlyFields f); + + [UnsafeAccessor(UnsafeAccessorKind.Field, Name="_rInt")] + extern static ref readonly int GetReadOnlyIntLocal(ref readonly ReadOnlyFields f); } [Fact] From 28117b9c05bf5e0a9b32af4814db2c3c1fc3e8d7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 09:28:22 +0100 Subject: [PATCH 09/20] [release/9.0-staging] [mono] Run runtime-llvm and runtime-ioslike on Mono LLVM PRs (#111739) Co-authored-by: Matous Kozak --- eng/pipelines/runtime-ioslike.yml | 18 ++++++++++++++++++ eng/pipelines/runtime-llvm.yml | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/eng/pipelines/runtime-ioslike.yml b/eng/pipelines/runtime-ioslike.yml index 1100ec500ce6ff..11477a3e175cba 100644 --- a/eng/pipelines/runtime-ioslike.yml +++ b/eng/pipelines/runtime-ioslike.yml @@ -4,6 +4,24 @@ trigger: none +# To reduce the load on the pipeline, enable it only for PRs that affect Mono LLVM related code. +pr: + branches: + include: + - main + - release/*.* + + paths: + include: + - src/mono/mono/mini/aot-*.* + - src/mono/mono/mini/llvm-*.* + - src/mono/mono/mini/mini-llvm-*.* + - src/mono/mono/mini/intrinsics.c + - src/mono/mono/mini/simd-*.* + - src/mono/mono/mini/decompose.c + - src/mono/mono/mini/method-to-ir.c + - src/mono/mono/mini/mini.c + variables: - template: /eng/pipelines/common/variables.yml diff --git a/eng/pipelines/runtime-llvm.yml b/eng/pipelines/runtime-llvm.yml index 5be2a5b063aaaa..6f3d16767ddbb3 100644 --- a/eng/pipelines/runtime-llvm.yml +++ b/eng/pipelines/runtime-llvm.yml @@ -28,6 +28,24 @@ schedules: - main always: false # run only if there were changes since the last successful scheduled run. +# To reduce the load on the pipeline, enable it only for PRs that affect Mono LLVM related code. +pr: + branches: + include: + - main + - release/*.* + + paths: + include: + - src/mono/mono/mini/aot-*.* + - src/mono/mono/mini/llvm-*.* + - src/mono/mono/mini/mini-llvm-*.* + - src/mono/mono/mini/intrinsics.c + - src/mono/mono/mini/simd-*.* + - src/mono/mono/mini/decompose.c + - src/mono/mono/mini/method-to-ir.c + - src/mono/mono/mini/mini.c + variables: - template: /eng/pipelines/common/variables.yml From db5ef4642da3709dfbead4a2c0f122950b7f61f5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 17:26:01 -0700 Subject: [PATCH 10/20] [release/9.0-staging] fix stack 2x2 tensor along dimension 1 (#110053) * fix stack 2x2 tensor along dimension 1 * fixed last stack errors --------- Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com> Co-authored-by: Michael Sharp --- .../Tensors/netcore/TensorExtensions.cs | 6 +-- .../tests/TensorTests.cs | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs index 6643f7c8a97434..8c8f02970db525 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorExtensions.cs @@ -3456,7 +3456,7 @@ public static Tensor StackAlongDimension(int dimension, params ReadOnlySpa Tensor[] outputs = new Tensor[tensors.Length]; for (int i = 0; i < tensors.Length; i++) { - outputs[i] = Tensor.Unsqueeze(tensors[0], dimension); + outputs[i] = Tensor.Unsqueeze(tensors[i], dimension); } return Tensor.ConcatenateOnDimension(dimension, outputs); } @@ -3494,9 +3494,9 @@ public static ref readonly TensorSpan StackAlongDimension(scoped ReadOnlyS Tensor[] outputs = new Tensor[tensors.Length]; for (int i = 0; i < tensors.Length; i++) { - outputs[i] = Tensor.Unsqueeze(tensors[0], dimension); + outputs[i] = Tensor.Unsqueeze(tensors[i], dimension); } - return ref Tensor.ConcatenateOnDimension(dimension, tensors, destination); + return ref Tensor.ConcatenateOnDimension(dimension, outputs, destination); } #endregion diff --git a/src/libraries/System.Numerics.Tensors/tests/TensorTests.cs b/src/libraries/System.Numerics.Tensors/tests/TensorTests.cs index f1886069e056ce..b1ad7a4c2d78cf 100644 --- a/src/libraries/System.Numerics.Tensors/tests/TensorTests.cs +++ b/src/libraries/System.Numerics.Tensors/tests/TensorTests.cs @@ -988,6 +988,7 @@ public static void TensorSetSliceTests() Assert.Equal(13, t0[1, 3]); Assert.Equal(14, t0[1, 4]); } + [Fact] public static void TensorStackTests() { @@ -1074,6 +1075,47 @@ public static void TensorStackTests() Assert.Equal(8, resultTensor[1, 3, 1]); Assert.Equal(9, resultTensor[1, 4, 0]); Assert.Equal(9, resultTensor[1, 4, 1]); + + // stacking 2x2 tensors along dimension 1 + Tensor v1 = Tensor.Create([1, 2, 3, 4], [2, 2]); + Tensor v2 = Tensor.Create([10, 20, 30, 40], [2, 2]); + + resultTensor = Tensor.StackAlongDimension(1, [v1, v2]); + + Assert.Equal(3, resultTensor.Rank); + Assert.Equal(2, resultTensor.Lengths[0]); + Assert.Equal(2, resultTensor.Lengths[1]); + Assert.Equal(2, resultTensor.Lengths[2]); + + Assert.Equal(1, resultTensor[0, 0, 0]); + Assert.Equal(2, resultTensor[0, 0, 1]); + Assert.Equal(10, resultTensor[0, 1, 0]); + Assert.Equal(20, resultTensor[0, 1, 1]); + + Assert.Equal(3, resultTensor[1, 0, 0]); + Assert.Equal(4, resultTensor[1, 0, 1]); + Assert.Equal(30, resultTensor[1, 1, 0]); + Assert.Equal(40, resultTensor[1, 1, 1]); + + resultTensor = Tensor.StackAlongDimension(0, [v1, v2]); + + Tensor resultTensor2 = Tensor.Create([2, 2, 2]); + Tensor.StackAlongDimension([v1, v2], resultTensor2, 1); + + Assert.Equal(3, resultTensor2.Rank); + Assert.Equal(2, resultTensor2.Lengths[0]); + Assert.Equal(2, resultTensor2.Lengths[1]); + Assert.Equal(2, resultTensor2.Lengths[2]); + + Assert.Equal(1, resultTensor2[0, 0, 0]); + Assert.Equal(2, resultTensor2[0, 0, 1]); + Assert.Equal(10, resultTensor2[0, 1, 0]); + Assert.Equal(20, resultTensor2[0, 1, 1]); + + Assert.Equal(3, resultTensor2[1, 0, 0]); + Assert.Equal(4, resultTensor2[1, 0, 1]); + Assert.Equal(30, resultTensor2[1, 1, 0]); + Assert.Equal(40, resultTensor2[1, 1, 1]); } [Fact] From ea5e814ba00d050073c1026e0c6800cb7208e310 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:23:56 -0800 Subject: [PATCH 11/20] [release/9.0-staging] Fix race condition in cleanup of collectible thread static variables (#111275) * Fix issue 110837 There was a race condition where we could have collected all of the managed state of a LoaderAllocator, but not yet started cleaning up the actual LoaderAllocator object in native code. If a thread which had a TLS variable defined in a code associated with a collectible loader allocator was terminated at that point, then the runtime would crash. The fix is to detect if the LoaderAllocator managed state is still alive, and if so, do not attempt to clean it up. * Disable test on NativeAOT * Update src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix missing adjustment missed by copilot --------- Co-authored-by: David Wrighton Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/coreclr/vm/threadstatics.cpp | 6 +- .../Statics/CollectibleTLSStaticCollection.cs | 103 ++++++++++++++++++ .../CollectibleTLSStaticCollection.csproj | 10 ++ src/tests/issues.targets | 3 + 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs create mode 100644 src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.csproj diff --git a/src/coreclr/vm/threadstatics.cpp b/src/coreclr/vm/threadstatics.cpp index 885453073508c5..889e9ea3cf4c63 100644 --- a/src/coreclr/vm/threadstatics.cpp +++ b/src/coreclr/vm/threadstatics.cpp @@ -377,7 +377,7 @@ void FreeLoaderAllocatorHandlesForTLSData(Thread *pThread) #endif for (const auto& entry : g_pThreadStaticCollectibleTypeIndices->CollectibleEntries()) { - _ASSERTE((entry.TlsIndex.GetIndexOffset() <= pThread->cLoaderHandles) || allRemainingIndicesAreNotValid); + _ASSERTE((entry.TlsIndex.GetIndexOffset() >= pThread->cLoaderHandles) || !allRemainingIndicesAreNotValid); if (entry.TlsIndex.GetIndexOffset() >= pThread->cLoaderHandles) { #ifndef _DEBUG @@ -390,7 +390,9 @@ void FreeLoaderAllocatorHandlesForTLSData(Thread *pThread) { if (pThread->pLoaderHandles[entry.TlsIndex.GetIndexOffset()] != (LOADERHANDLE)NULL) { - entry.pMT->GetLoaderAllocator()->FreeHandle(pThread->pLoaderHandles[entry.TlsIndex.GetIndexOffset()]); + LoaderAllocator *pLoaderAllocator = entry.pMT->GetLoaderAllocator(); + if (pLoaderAllocator->IsExposedObjectLive()) + pLoaderAllocator->FreeHandle(pThread->pLoaderHandles[entry.TlsIndex.GetIndexOffset()]); pThread->pLoaderHandles[entry.TlsIndex.GetIndexOffset()] = (LOADERHANDLE)NULL; } } diff --git a/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs b/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs new file mode 100644 index 00000000000000..d84d3d05769c80 --- /dev/null +++ b/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.cs @@ -0,0 +1,103 @@ +// 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.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading; +using Xunit; + +namespace CollectibleThreadStaticShutdownRace +{ + public class CollectibleThreadStaticShutdownRace + { + Action? UseTLSStaticFromLoaderAllocator = null; + GCHandle IsLoaderAllocatorLive; + static ulong s_collectibleIndex; + + [MethodImpl(MethodImplOptions.NoInlining)] + void CallUseTLSStaticFromLoaderAllocator() + { + UseTLSStaticFromLoaderAllocator!(); + UseTLSStaticFromLoaderAllocator = null; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + bool CheckLALive() + { + return IsLoaderAllocatorLive.Target != null; + } + + + void ThreadThatWaitsForLoaderAllocatorToDisappear() + { + CallUseTLSStaticFromLoaderAllocator(); + while (CheckLALive()) + { + GC.Collect(2); + } + } + + void CreateLoaderAllocatorWithTLS() + { + ulong collectibleIndex = s_collectibleIndex++; + + var ab = + AssemblyBuilder.DefineDynamicAssembly( + new AssemblyName($"CollectibleDerivedAssembly{collectibleIndex}"), + AssemblyBuilderAccess.RunAndCollect); + var mob = ab.DefineDynamicModule($"CollectibleDerivedModule{collectibleIndex}"); + var tb = + mob.DefineType( + $"CollectibleDerived{collectibleIndex}", + TypeAttributes.Class | TypeAttributes.Public, + typeof(object)); + + { + var fb = + tb.DefineField( + "Field", typeof(int), FieldAttributes.Static); + fb.SetCustomAttribute(typeof(ThreadStaticAttribute).GetConstructors()[0], new byte[0]); + + var mb = + tb.DefineMethod( + "Method", + MethodAttributes.Public | MethodAttributes.Static); + var ilg = mb.GetILGenerator(); + ilg.Emit(OpCodes.Ldc_I4_1); + ilg.Emit(OpCodes.Stsfld, fb); + ilg.Emit(OpCodes.Ret); + } + + Type createdType = tb.CreateType(); + UseTLSStaticFromLoaderAllocator = (Action)createdType.GetMethods()[0].CreateDelegate(typeof(Action)); + IsLoaderAllocatorLive = GCHandle.Alloc(createdType, GCHandleType.WeakTrackResurrection); + } + + void ForceCollectibleTLSStaticToGoThroughThreadTermination() + { + int iteration = 0; + for (int i = 0; i < 10; i++) + { + Console.WriteLine($"Iteration {iteration++}"); + var createLAThread = new Thread(CreateLoaderAllocatorWithTLS); + createLAThread.Start(); + createLAThread.Join(); + + var crashThread = new Thread(ThreadThatWaitsForLoaderAllocatorToDisappear); + crashThread.Start(); + crashThread.Join(); + } + + } + + [Fact] + public static void TestEntryPoint() + { + new CollectibleThreadStaticShutdownRace().ForceCollectibleTLSStaticToGoThroughThreadTermination(); + } + } +} + diff --git a/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.csproj b/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.csproj new file mode 100644 index 00000000000000..b2bf6ae30660e7 --- /dev/null +++ b/src/tests/Loader/CollectibleAssemblies/Statics/CollectibleTLSStaticCollection.csproj @@ -0,0 +1,10 @@ + + + + true + true + + + + + diff --git a/src/tests/issues.targets b/src/tests/issues.targets index e03e2fe28bd388..b246551a819603 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1010,6 +1010,9 @@ https://github.com/dotnet/runtimelab/issues/155: Collectible assemblies + + https://github.com/dotnet/runtimelab/issues/155: Collectible assemblies + https://github.com/dotnet/runtimelab/issues/155: Collectible assemblies From 6061b2c590ca4af38f5b5dadd71232eb15fa7885 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:27:17 +0100 Subject: [PATCH 12/20] [release/9.0-staging] [iOS] Retrieve device locale in full (specific) format from ObjectiveC APIs (#111612) --- .../CultureInfo/CultureInfoCurrentCulture.cs | 9 +++++++++ .../libs/System.Globalization.Native/pal_locale.m | 11 ++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs index 9c34a6a128a873..f7fa352690c3f4 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs @@ -44,6 +44,15 @@ public void CurrentCulture_Default_Not_Invariant() Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture); } + [Fact] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "https://github.com/dotnet/runtime/issues/111501")] + public void CurrentCulture_Default_Is_Specific() + { + // On OSX-like platforms, the current culture taken from default system culture should be specific. + Assert.False(CultureInfo.CurrentCulture.IsNeutralCulture); + } + [Fact] public void CurrentCulture_Set_Null_ThrowsArgumentNullException() { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 6d13c807bec95d..a26cc318f14613 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -786,13 +786,6 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } -static NSString* GetBaseName(NSString *localeIdentifier) -{ - NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier]; - NSString *languageCode = [locale objectForKey:NSLocaleLanguageCode]; - return languageCode; -} - const char* GlobalizationNative_GetDefaultLocaleNameNative(void) { @autoreleasepool @@ -800,7 +793,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) if (NSLocale.preferredLanguages.count > 0) { NSString *preferredLanguage = [NSLocale.preferredLanguages objectAtIndex:0]; - return strdup([GetBaseName(preferredLanguage) UTF8String]); + return strdup([preferredLanguage UTF8String]); } else { @@ -821,7 +814,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) localeName = currentLocale.localeIdentifier; } - return strdup([GetBaseName(localeName) UTF8String]); + return strdup([localeName UTF8String]); } } } From 62d433f2133fd41aefe36b1a97f7c06f28c5929b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:15:16 -0600 Subject: [PATCH 13/20] [release/9.0-staging] Add workflow to prevent merging a PR when the `NO-MERGE` label is applied (#111961) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add workflow to prevent merging a PR when the `NO-MERGE` label is applied. * Invert condition * Fix backtick bug in check-service-labels echo. --------- Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com> --- .github/workflows/check-no-merge-label.yml | 25 ++++++++++++++++++++++ .github/workflows/check-service-labels.yml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-no-merge-label.yml diff --git a/.github/workflows/check-no-merge-label.yml b/.github/workflows/check-no-merge-label.yml new file mode 100644 index 00000000000000..1c01c2f7324175 --- /dev/null +++ b/.github/workflows/check-no-merge-label.yml @@ -0,0 +1,25 @@ +name: check-no-merge-label + +permissions: + pull-requests: read + +on: + pull_request: + types: [opened, edited, reopened, labeled, unlabeled, synchronize] + branches: + - 'main' + - 'release/**' + +jobs: + check-labels: + runs-on: ubuntu-latest + steps: + - name: Check 'NO-MERGE' label + run: | + echo "Merging permission is disabled when the 'NO-MERGE' label is applied." + if [ "${{ contains(github.event.pull_request.labels.*.name, 'NO-MERGE') }}" = "false" ]; then + exit 0 + else + echo "::error:: The 'NO-MERGE' label was applied to the PR. Merging is disabled." + exit 1 + fi diff --git a/.github/workflows/check-service-labels.yml b/.github/workflows/check-service-labels.yml index 5261cc165ee128..2d85e4d278a393 100644 --- a/.github/workflows/check-service-labels.yml +++ b/.github/workflows/check-service-labels.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Check 'Servicing-approved' label run: | - echo "Merging permission is enabled for servicing PRs when the `Servicing-approved` label is applied." + echo "Merging permission is enabled for servicing PRs when the 'Servicing-approved' label is applied." if [ "${{ contains(github.event.pull_request.labels.*.name, 'Servicing-approved') }}" = "true" ]; then exit 0 else From 99b4e84899f351cacf6e881371a50cb8311013e6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 09:39:46 -0800 Subject: [PATCH 14/20] Use alternative format (#111444) --- src/coreclr/ildasm/dasm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index f94a5846672d96..7c2b3eabd36597 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -1914,7 +1914,7 @@ BYTE* PrettyPrintCABlobValue(PCCOR_SIGNATURE &typePtr, for(n=0; n < numElements; n++) { if(n) appendStr(out," "); - sprintf_s(str, 64, "%.*g", 8, (double)(*((float*)dataPtr))); + sprintf_s(str, 64, "%#.8g", (double)(*((float*)dataPtr))); float df = (float)atof(str); // Must compare as underlying bytes, not floating point otherwise optimizer will // try to enregister and compare 80-bit precision number with 32-bit precision number!!!! @@ -1933,7 +1933,7 @@ BYTE* PrettyPrintCABlobValue(PCCOR_SIGNATURE &typePtr, { if(n) appendStr(out," "); char *pch; - sprintf_s(str, 64, "%.*g", 17, *((double*)dataPtr)); + sprintf_s(str, 64, "%#.17g", *((double*)dataPtr)); double df = strtod(str, &pch); // Must compare as underlying bytes, not floating point otherwise optimizer will // try to enregister and compare 80-bit precision number with 64-bit precision number!!!! @@ -2605,7 +2605,7 @@ void DumpDefaultValue(mdToken tok, __inout __nullterminated char* szString, void case ELEMENT_TYPE_R4: { char szf[32]; - sprintf_s(szf, 32, "%.*g", 8, (double)MDDV.m_fltValue); + sprintf_s(szf, 32, "%#.8g", (double)MDDV.m_fltValue); float df = (float)atof(szf); // Must compare as underlying bytes, not floating point otherwise optimizer will // try to enregister and compare 80-bit precision number with 32-bit precision number!!!! @@ -2619,7 +2619,7 @@ void DumpDefaultValue(mdToken tok, __inout __nullterminated char* szString, void case ELEMENT_TYPE_R8: { char szf[32], *pch; - sprintf_s(szf, 32, "%.*g", 17, MDDV.m_dblValue); + sprintf_s(szf, 32, "%#.17g", MDDV.m_dblValue); double df = strtod(szf, &pch); //atof(szf); szf[31]=0; // Must compare as underlying bytes, not floating point otherwise optimizer will From 77e45d3502acc10fe55092021316f7d1c6c70785 Mon Sep 17 00:00:00 2001 From: Jeremi Kurdek <59935235+jkurdek@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:33:54 +0100 Subject: [PATCH 15/20] Fixed referring to `_LibClang` item (#111696) --- src/mono/mono.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 480f9e15048390..8bfbb710823937 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -818,8 +818,8 @@ JS_ENGINES = [NODE_JS] <_LibClang Include="$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/lib/libclang.so" Condition=" Exists('$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/lib/libclang.so') "/> - <_LibClang Include="$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/lib64/libclang.so.*" Condition=" '$(_LibClang)' == '' "/> - <_LibClang Include="/usr/local/lib/libclang.so" Condition="'$(_LibClang)' == ''" /> + <_LibClang Include="$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/lib64/libclang.so.*" Condition=" '@(_LibClang)' == '' "/> + <_LibClang Include="/usr/local/lib/libclang.so" Condition="'@(_LibClang)' == ''" /> true From 6091bce530206a4895505582d45fd437a3232c99 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Feb 2025 19:45:08 -0800 Subject: [PATCH 16/20] [release/9.0-staging] Fix UNC paths (#111499) * Fix UNC paths If the input file was a network path then the raw path returned by GetFinalPathByHandle may return a UNC path. If so, and if the original path wasn't a UNC path, and the original path doesn't need normalization, we want to use the original path. * Use MAXPATH instead * Update src/native/corehost/hostmisc/pal.windows.cpp Co-authored-by: Elinor Fung * Update src/native/corehost/hostmisc/pal.windows.cpp Co-authored-by: Elinor Fung --------- Co-authored-by: Andy Gocke Co-authored-by: Elinor Fung --- src/native/corehost/hostmisc/pal.windows.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/native/corehost/hostmisc/pal.windows.cpp b/src/native/corehost/hostmisc/pal.windows.cpp index 3a3db968b5bde4..3479c72aced1de 100644 --- a/src/native/corehost/hostmisc/pal.windows.cpp +++ b/src/native/corehost/hostmisc/pal.windows.cpp @@ -884,8 +884,12 @@ bool pal::realpath(pal::string_t* path, bool skip_error_logging) } } - // Remove the \\?\ prefix, unless it is necessary or was already there - if (LongFile::IsExtended(str) && !LongFile::IsExtended(*path) && + // Remove the UNC extended prefix (\\?\UNC\) or extended prefix (\\?\) unless it is necessary or was already there + if (LongFile::IsUNCExtended(str) && !LongFile::IsUNCExtended(*path) && str.length() < MAX_PATH) + { + str.replace(0, LongFile::UNCExtendedPathPrefix.size(), LongFile::UNCPathPrefix); + } + else if (LongFile::IsExtended(str) && !LongFile::IsExtended(*path) && !LongFile::ShouldNormalize(str.substr(LongFile::ExtendedPrefix.size()))) { str.erase(0, LongFile::ExtendedPrefix.size()); From 2e3dd8ed5f8994c8a8c7b6610a11aeed6113b359 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 14:05:28 +0100 Subject: [PATCH 17/20] [release/9.0-staging] [mono] [llvm-aot] Fixed storing Vector3 into memory (#111069) * [mono] [llvm-aot] Fixed storing Vector3 into memory * Removed unused variable --------- Co-authored-by: Jeremi Kurdek --- src/mono/mono/mini/mini-llvm.c | 16 ++++++++++++- .../JitBlue/Runtime_110820/Runtime_110820.cs | 24 +++++++++++++++++++ .../Runtime_110820/Runtime_110820.csproj | 8 +++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.csproj diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 29c8af40b4153d..8cc8c986381b52 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -8433,7 +8433,21 @@ MONO_RESTORE_WARNING LLVMValueRef dest; dest = convert (ctx, LLVMBuildAdd (builder, convert (ctx, values [ins->inst_destbasereg], IntPtrType ()), LLVMConstInt (IntPtrType (), ins->inst_offset, FALSE), ""), pointer_type (t)); - mono_llvm_build_aligned_store (builder, lhs, dest, FALSE, 1); + if (mono_class_value_size (ins->klass, NULL) == 12) { + const int mask_values [] = { 0, 1, 2 }; + + LLVMValueRef truncatedVec3 = LLVMBuildShuffleVector ( + builder, + lhs, + LLVMGetUndef (t), + create_const_vector_i32 (mask_values, 3), + "truncated_vec3" + ); + + mono_llvm_build_aligned_store (builder, truncatedVec3, dest, FALSE, 1); + } else { + mono_llvm_build_aligned_store (builder, lhs, dest, FALSE, 1); + } break; } case OP_XBINOP: diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.cs b/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.cs new file mode 100644 index 00000000000000..c4abf023a4df92 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit; +using System.Numerics; + +public class Foo +{ + public Vector3 v1; + public Vector3 v2; +} + +public class Runtime_110820 +{ + [Fact] + public static void TestEntryPoint() + { + var foo = new Foo(); + foo.v2 = new Vector3(4, 5, 6); + foo.v1 = new Vector3(1, 2, 3); + Assert.Equal(new Vector3(1, 2, 3), foo.v1); + Assert.Equal(new Vector3(4, 5, 6), foo.v2); + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.csproj new file mode 100644 index 00000000000000..de6d5e08882e86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_110820/Runtime_110820.csproj @@ -0,0 +1,8 @@ + + + True + + + + + From bfcb495aa86ac846cdf6aca39801fc7b0b6b5bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:01:32 -0800 Subject: [PATCH 18/20] Change workflows to use pull_request_target instead of pull_request event --- .github/workflows/check-no-merge-label.yml | 4 ++-- .github/workflows/check-service-labels.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-no-merge-label.yml b/.github/workflows/check-no-merge-label.yml index 1c01c2f7324175..37cc7adf20596b 100644 --- a/.github/workflows/check-no-merge-label.yml +++ b/.github/workflows/check-no-merge-label.yml @@ -4,8 +4,8 @@ permissions: pull-requests: read on: - pull_request: - types: [opened, edited, reopened, labeled, unlabeled, synchronize] + pull_request_target: + types: [labeled, unlabeled] branches: - 'main' - 'release/**' diff --git a/.github/workflows/check-service-labels.yml b/.github/workflows/check-service-labels.yml index 2d85e4d278a393..9726087abbf4dc 100644 --- a/.github/workflows/check-service-labels.yml +++ b/.github/workflows/check-service-labels.yml @@ -4,8 +4,8 @@ permissions: pull-requests: read on: - pull_request: - types: [opened, edited, reopened, labeled, unlabeled, synchronize] + pull_request_target: + types: [labeled, unlabeled] branches: - 'release/**' From 366eb6d95b5d729af4b27c1d1ac2bb1f9979209a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:01:40 -0800 Subject: [PATCH 19/20] Add CODEOWNERS entry --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2d544524862e2d..932711bd1081fc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -113,3 +113,4 @@ /docs/area-owners.* @jeffhandley /docs/issue*.md @jeffhandley /.github/policies/ @jeffhandley @mkArtakMSFT +/.github/workflows/ @dotnet/runtime-infrastructure From c901d1da9eda536c7d622c16a687cc9d36ec1708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:01:47 -0800 Subject: [PATCH 20/20] Add initial readme --- .github/workflows/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/workflows/README.md diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000000..308cb2d1a85b6b --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,6 @@ +# Workflows + +General guidance: + +- Please make sure to include the @dotnet/runtime-infrastructure group as a reviewer of your PRs. +- Do not use the `pull_request` event. Use `pull_request_target` instead, as documented in [Workflows in forked repositories](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflows-in-forked-repositories) and [pull_request_target](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target).