From 495a5ef96522246b76b0f1bfe73964f91e8afc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 24 Jan 2023 15:29:40 +0100 Subject: [PATCH 1/3] Always allocation on wasm when computing temp path. --- .../System.Private.CoreLib/src/System/IO/Path.Unix.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs index c6b4d904e25865..53d715753c7da4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs @@ -103,7 +103,11 @@ public static unsafe string GetTempFileName() int tempPathByteCount = Encoding.UTF8.GetByteCount(tempPath); int totalByteCount = tempPathByteCount + fileTemplate.Length + 1; +#if TARGET_BROWSER + Span path = new byte[totalByteCount]; +#else Span path = totalByteCount <= 256 ? stackalloc byte[256].Slice(0, totalByteCount) : new byte[totalByteCount]; +#endif int pos = Encoding.UTF8.GetBytes(tempPath, path); fileTemplate.CopyTo(path.Slice(pos)); path[^1] = 0; From 20055840801669d98ff34f98942bbcea45d69951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 25 Jan 2023 10:59:21 +0100 Subject: [PATCH 2/3] Enable tests. --- .../tests/System/CodeDom/Compiler/CodeCompilerTests.cs | 8 -------- .../tests/CtorsDelimiterTests.cs | 1 - .../tests/XmlWriterTraceListenerTests.cs | 1 - .../tests/BasicScenarioTests.cs | 2 -- 4 files changed, 12 deletions(-) diff --git a/src/libraries/System.CodeDom/tests/System/CodeDom/Compiler/CodeCompilerTests.cs b/src/libraries/System.CodeDom/tests/System/CodeDom/Compiler/CodeCompilerTests.cs index 244931f1f5876b..7a53cd95b1d9eb 100644 --- a/src/libraries/System.CodeDom/tests/System/CodeDom/Compiler/CodeCompilerTests.cs +++ b/src/libraries/System.CodeDom/tests/System/CodeDom/Compiler/CodeCompilerTests.cs @@ -55,7 +55,6 @@ public void CompileAssemblyFromDom_NullOptions_ThrowsArgumentNullException() [Theory] [MemberData(nameof(CodeCompileUnit_TestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void FromDom_ValidCodeCompileUnit_ReturnsExpected(CodeCompileUnit compilationUnit) { var compiler = new StubCompiler(); @@ -67,7 +66,6 @@ public void FromDom_ValidCodeCompileUnit_ReturnsExpected(CodeCompileUnit compila [Theory] [MemberData(nameof(CodeCompileUnit_TestData))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void FromDom_ValidCodeCompileUnit_ThrowsPlatformNotSupportedException(CodeCompileUnit compilationUnit) { var compiler = new Compiler(); @@ -363,7 +361,6 @@ public void CompileAssemblyFromSource_NullOptions_ThrowsArgumentNullException() } [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] [MemberData(nameof(Source_TestData))] public void FromSource_ValidSource_ReturnsExpected(string source) { @@ -374,7 +371,6 @@ public void FromSource_ValidSource_ReturnsExpected(string source) [Theory] [MemberData(nameof(Source_TestData))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void FromSource_ValidSource_ThrowsPlatformNotSupportedException(string source) { var compiler = new Compiler(); @@ -398,7 +394,6 @@ public static IEnumerable Sources_TestData() [Theory] [MemberData(nameof(Sources_TestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void CompileAssemblyFromSourceBatch_ValidSources_ReturnsExpected(string[] sources) { ICodeCompiler compiler = new StubCompiler(); @@ -430,7 +425,6 @@ public void CompileAssemblyFromSourceBatch_NullSources_ThrowsArgumentNullExcepti [Theory] [MemberData(nameof(Sources_TestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void FromSourceBatch_ValidSources_ReturnsExpected(string[] sources) { var compiler = new StubCompiler(); @@ -440,7 +434,6 @@ public void FromSourceBatch_ValidSources_ReturnsExpected(string[] sources) [Theory] [MemberData(nameof(Sources_TestData))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void FromSourceBatch_ValidSources_ThrowsPlatformNotSupportedException(string[] sources) { var compiler = new Compiler(); @@ -466,7 +459,6 @@ public void FromSourceBatch_NullSources_ThrowsArgumentNullException() [InlineData("")] [InlineData("cmdArgs")] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Occasionally fails in .NET framework, probably caused from a very edge case bug in .NET Framework which we will not be fixing")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void GetResponseFileCmdArgs_ValidCmdArgs_ReturnsExpected(string cmdArgs) { var compiler = new Compiler(); diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/CtorsDelimiterTests.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/CtorsDelimiterTests.cs index cb4059bc43e72c..352d0d1a6b29cb 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/CtorsDelimiterTests.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/CtorsDelimiterTests.cs @@ -114,7 +114,6 @@ public void TestConstructorWithFileName() [Theory] [MemberData(nameof(TestNames))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void TestConstructorWithFileNameAndName(string testName) { var target = new DelimitedListTraceListener(Path.GetTempFileName(), testName); diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs index 46638320c0cdb0..20576cc9190b91 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs @@ -44,7 +44,6 @@ public static IEnumerable ConstructorsTestData() [Theory] [MemberData(nameof(ConstructorsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public void SingleArgumentConstructorTest(XmlWriterTraceListener listener, string expectedName) { Assert.Equal(expectedName, listener.Name); diff --git a/src/libraries/System.ServiceModel.Syndication/tests/BasicScenarioTests.cs b/src/libraries/System.ServiceModel.Syndication/tests/BasicScenarioTests.cs index e3df3f845677f0..f1269d75e0a2d5 100644 --- a/src/libraries/System.ServiceModel.Syndication/tests/BasicScenarioTests.cs +++ b/src/libraries/System.ServiceModel.Syndication/tests/BasicScenarioTests.cs @@ -44,7 +44,6 @@ public static void SyndicationFeed_CreateNewFeed() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/77526", TestPlatforms.Browser)] public static void SyndicationFeed_Load_Write_RSS_Feed() { string path = Path.GetTempFileName(); @@ -178,7 +177,6 @@ public static void SyndicationFeed_Load_Write_Atom_Feed_() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73721", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJSOnWindows))] public static void SyndicationFeed_Write_RSS_Atom() { string RssPath = Path.GetTempFileName(); From 96e2b1b539a8702e456558da42556e7080378417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 26 Jan 2023 11:33:10 +0100 Subject: [PATCH 3/3] Add link to emscripten issue and describe why we allocate on heap. --- src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs index 53d715753c7da4..e7b21263a8be1f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs @@ -104,6 +104,8 @@ public static unsafe string GetTempFileName() int totalByteCount = tempPathByteCount + fileTemplate.Length + 1; #if TARGET_BROWSER + // https://github.com/emscripten-core/emscripten/issues/18591 + // The emscripten implementation of __randname uses pointer address as another entry into the randomness. Span path = new byte[totalByteCount]; #else Span path = totalByteCount <= 256 ? stackalloc byte[256].Slice(0, totalByteCount) : new byte[totalByteCount];