Skip to content

Commit

Permalink
[wasm] Always allocate when computing temp file name (#81085)
Browse files Browse the repository at this point in the history
The wasm implementation of __randname uses pointer address as another entry into the randomness.
  • Loading branch information
maraf authored Jan 26, 2023
1 parent a2c4d79 commit 79e1abf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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();
Expand All @@ -398,7 +394,6 @@ public static IEnumerable<object[]> 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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static IEnumerable<object[]> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ public static unsafe string GetTempFileName()
int tempPathByteCount = Encoding.UTF8.GetByteCount(tempPath);
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<byte> path = new byte[totalByteCount];
#else
Span<byte> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 79e1abf

Please sign in to comment.