-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix #84344 to ensure sufficient stack by calling RuntimeHelpers.EnsureSufficientExecutionStack() #122761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix #84344 to ensure sufficient stack by calling RuntimeHelpers.EnsureSufficientExecutionStack() #122761
Changes from all commits
ec6b7aa
bb759a2
063b473
44a9026
4aee8a7
4a97e0c
f5469d8
56de673
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -288,6 +288,24 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Delete(rootDirectory, recursive: true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [Fact] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [PlatformSpecific(TestPlatforms.Windows)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [PlatformSpecific(TestPlatforms.Windows)] | |
| [PlatformSpecific(TestPlatforms.Windows)] | |
| [OuterLoop("This test is very slow.", ~TestPlatforms.Browser)] |
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Release NativeAOT_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug Mono_Interpreter_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests_EAT)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-arm checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-x64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-arm64 checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-x64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Release NativeAOT_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-x64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 300 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L300
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(300,36): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'testDir' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Release NativeAOT_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug Mono_Interpreter_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests_EAT)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-arm checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build browser-wasm linux Release LibraryTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-x64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-arm64 checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux_musl-x64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-arm64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build linux-x64 checked CoreCLR_ReleaseLibraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Release NativeAOT_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Debug CoreCLR_Libraries)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-x64 Debug Mono_MiniJIT_LibrariesTests)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Check failure on line 301 in src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs
Azure Pipelines / runtime (Build osx-arm64 Debug Libraries_CheckedCoreCLR)
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs#L301
src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete.cs(301,33): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'depth' does not exist in the current context
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a very deep nesting (9000) using CreateSubdirectory in a tight loop, but the test isn't marked [OuterLoop]. This is likely to be very slow/flaky in CI and duplicates coverage with the existing RecursiveDelete_DeepNesting test just above. Consider reusing/adjusting the existing deep-nesting test (including its [OuterLoop] annotation) rather than adding a second long-running variant.
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test currently deletes only the leaf directory: subDir is reassigned in the loop to the deepest "a" directory, so Directory.Delete(subDir.FullName, recursive: true) won't exercise recursive deletion and will leave thousands of parent directories behind. Keep a reference to the top of the created tree (e.g., the initial test_issue84344 directory or testDir) and delete that instead; also ensure cleanup on failure (e.g., via try/finally) to avoid polluting the test temp root.
| DirectoryInfo subDir = testDir.CreateSubdirectory("test_issue84344"); | |
| for (int i = 0; i < depth; i++) | |
| { | |
| subDir = subDir.CreateSubdirectory("a"); | |
| } | |
| // Now delete the subdir recursively. | |
| Directory.Delete(subDir.FullName, recursive: true); | |
| DirectoryInfo rootSubDir = testDir.CreateSubdirectory("test_issue84344"); | |
| DirectoryInfo currentSubDir = rootSubDir; | |
| for (int i = 0; i < depth; i++) | |
| { | |
| currentSubDir = currentSubDir.CreateSubdirectory("a"); | |
| } | |
| // Now delete the subdir recursively, starting from the top of the created tree. | |
| try | |
| { | |
| Directory.Delete(rootSubDir.FullName, recursive: true); | |
| } | |
| finally | |
| { | |
| try | |
| { | |
| if (rootSubDir.Exists) | |
| { | |
| Directory.Delete(rootSubDir.FullName, recursive: true); | |
| } | |
| } | |
| catch (IOException) | |
| { | |
| } | |
| catch (UnauthorizedAccessException) | |
| { | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned this is going to start introducing failures that weren't there before. Previously if we recurred too deeply the process would crash with a stack overflow, but EnsureSufficientExecutionStack is fairly conservative about what "sufficient execution stack" means, and it could end up throwing an exception well before the process would otherwise crash. I expect there are some cases today of very nested directories that are working today because they're not deep enough to cause a crash but would start throwing an exception with this because they are deep enough to hit the stack execution depth limit.
Alternatives might include:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank yoju for the feedback, @stephentoub ! 👍
Let me refactor it.