Skip to content
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

\ character in directory name prevents compilation #40410

Open
AdamSlayer opened this issue Apr 23, 2024 · 2 comments
Open

\ character in directory name prevents compilation #40410

AdamSlayer opened this issue Apr 23, 2024 · 2 comments
Labels
Area-CLI Area-Run Issues relating to `dotnet run` Bug
Milestone

Comments

@AdamSlayer
Copy link

Description

Command dotnet run fails with an internal stack overflow error when there is a folder named \ present in the project root. It seems like it encounters an infinite recursion.

Reproduction Steps

  1. Use a Unix-based system that allows a directory to be named \
  2. Create a new empty c# project (you can use dotnet new)
  3. Create a new folder named \ (you can use mkdir \\
  4. Run dotnet run, it will fail on stack overflow likely due to infinite recursion.

Expected behavior

dotnet run builds and runs the project

Actual behavior

dotnet run fails on stack overflow due to infinite recursion. Dotnet 8 shows no stack trace, just says stack overflow. Below is stack trace from dotnet 6.0.0, shortened because it was very long.

mkdir \\
dotnet run
Stack overflow.
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass19_0.<.ctor>b__0(FileSystemEntity, System.String, System.String, System.String, Boolean)
   at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass41_0.<GetFilesRecursive>b__0(System.String)
   at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass19_0.<.ctor>b__0(FileSystemEntity, System.String, System.String, System.String, Boolean)
   at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass41_0.<GetFilesRecursive>b__0(System.String)
   at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)


... a lot more recursion ...
  
Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass41_0.<GetFilesRecursive>b__0(System.String)
   at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(System.Collections.Concurrent.ConcurrentStack`1<System.Collections.Generic.List`1<System.String>>, RecursionState, System.String, Boolean, System.Collections.Generic.IList`1<RecursionState>, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<RecursionState>>, TaskOptions)
   at Microsoft.Build.Shared.FileMatcher+<>c__DisplayClass41_0.<GetFilesRecursive>b__0(System.String)
   at System.Threading.Tasks.Parallel+<>c__DisplayClass32_0`2[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForEachWorker>b__0(Int32)
   at System.Threading.Tasks.Parallel+<>c__DisplayClass19_0`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(System.Threading.Tasks.RangeWorker ByRef, Int32, Boolean ByRef)
   at System.Threading.Tasks.TaskReplicator+Replica.Execute()
   at System.Threading.Tasks.TaskReplicator+Replica+<>c.<.ctor>b__4_0(System.Object)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(System.Object)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()
zsh: abort      dotnet run

Regression?

No response

Known Workarounds

  1. Don't create a folder named \
  2. Use Windows or another non-Unix-based OS (not recommended, windows is bad)

Configuration

dotnet 8.0.x fails, dotnet 6.0.0 fails, not tested for other versions.
MacOS Sonoma 14.4, M3 chip, architecture aarch64

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged Request triage from a team member label Apr 23, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

@eiriktsarpalis eiriktsarpalis transferred this issue from dotnet/runtime Apr 24, 2024
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@MiYanni MiYanni added Area-CLI Area-Run Issues relating to `dotnet run` and removed untriaged Request triage from a team member type-investigation labels Mar 6, 2025
@MiYanni MiYanni added this to the 10.0.1xx milestone Mar 7, 2025
@MiYanni MiYanni removed their assignment Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI Area-Run Issues relating to `dotnet run` Bug
Projects
None yet
Development

No branches or pull requests

2 participants