Skip to content

Path.GetTempFileName() sometimes fails on WASM due to insufficient randomness #73721

Closed
@radical

Description

@radical

Build, seen on multiple PRs with no related changes. Which suggests that this is on main. Failures like:

[19:23:32] info: Starting:    System.CodeDom.Tests.dll
[19:23:39] fail: [FAIL] System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSource_ValidSource_ReturnsExpected(source: "")
[19:23:39] info: System.IO.IOException : File exists
[19:23:39] info:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory)
[19:23:39] info:    at Interop.ThrowIOExceptionForLastError()
[19:23:39] info:    at System.IO.Directory.CreateTempSubdirectoryCore(String prefix)
[19:23:39] info:    at System.IO.Directory.CreateTempSubdirectory(String prefix)
[19:23:39] info:    at System.CodeDom.Compiler.TempFileCollection.GetTempDirectory()
[19:23:39] info:    at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
[19:23:39] info:    at System.CodeDom.Compiler.TempFileCollection.get_BasePath()
[19:23:39] info:    at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile)
[19:23:39] info:    at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension)
[19:23:39] info:    at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters options, String[] sources)
[19:23:39] info:    at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters options, String source)
[19:23:39] info:    at System.CodeDom.Compiler.Tests.CodeCompilerTests.Compiler.FromSourceEntryPoint(CompilerParameters options, String source)
[19:23:39] info:    at System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSource_ValidSource_ReturnsExpected(String source)
[19:23:39] info:    at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)

.. and ..

[19:27:13] info: Starting:    System.Diagnostics.TextWriterTraceListener.Tests.dll
[19:27:14] fail: [FAIL] System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(testName: "")
[19:27:14] info: System.IO.IOException : File exists
[19:27:14] info:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory)
[19:27:14] info:    at Interop.CheckIo(Int64 result, String path, Boolean isDirectory)
[19:27:14] info:    at Interop.CheckIo(IntPtr result, String path, Boolean isDirectory)
[19:27:14] info:    at System.IO.Path.GetTempFileName()
[19:27:14] info:    at System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(String testName)
[19:27:14] info:    at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
[19:27:14] fail: [FAIL] System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(testName: "><&")
[19:27:14] info: System.IO.IOException : File exists
[19:27:14] info:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory)
[19:27:14] info:    at Interop.CheckIo(Int64 result, String path, Boolean isDirectory)
[19:27:14] info:    at Interop.CheckIo(IntPtr result, String path, Boolean isDirectory)
[19:27:14] info:    at System.IO.Path.GetTempFileName()
[19:27:14] info:    at System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(String testName)
[19:27:14] info:    at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)

Just for people reading this in the future, the list of failed tests:

System.CodeDom.Compiler.Tests.CodeCompilerTests.FromDom_ValidCodeCompileUnit_ReturnsExpected(compilationUnit: CodeCompileUnit { AssemblyCustomAttributes = [], EndDirectives = [], Namespaces = [], ReferencedAssemblies = ["assembly1", "assembly2"], StartDirectives = [], ... })
System.CodeDom.Compiler.Tests.CodeCompilerTests.GetResponseFileCmdArgs_ValidCmdArgs_ReturnsExpected(cmdArgs: "")
System.CodeDom.Compiler.Tests.CodeCompilerTests.CompileAssemblyFromSourceBatch_ValidSources_ReturnsExpected(sources: [null])
System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSource_ValidSource_ReturnsExpected(source: "")
System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSourceBatch_ValidSources_ReturnsExpected(sources: [""])
System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSource_ValidSource_ThrowsPlatformNotSupportedException(source: "")
System.CodeDom.Compiler.Tests.CodeCompilerTests.FromDom_ValidCodeCompileUnit_ThrowsPlatformNotSupportedException(compilationUnit: CodeCompileUnit { AssemblyCustomAttributes = [], EndDirectives = [], Namespaces = [], ReferencedAssemblies = ["referenced", "assembly1"], StartDirectives = [], ... })
System.CodeDom.Compiler.Tests.CodeCompilerTests.FromSourceBatch_ValidSources_ThrowsPlatformNotSupportedException(sources: [""])

System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(testName: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...)
System.Diagnostics.TextWriterTraceListenerTests.CtorsDelimiterTests.TestConstructorWithFileNameAndName(testName: "><&")
System.Diagnostics.TextWriterTraceListenerTests.XmlWriterTraceListenerTests.SingleArgumentConstructorTest

 ystem.ServiceModel.Syndication.Tests.BasicScenarioTests.SyndicationFeed_Write_RSS_Atom

The full set can be seen with that build url. I think #73408 broke these tests.

@eerhardt

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions