Skip to content

std::fs::create_dir_all will stack overflow with big paths #124309

@xTachyon

Description

@xTachyon

I tried this code:

std::fs::create_dir_all(big_path);

I expected to see this happen: doesn't stack overflow

Instead, this happened:
std::fs::create_dir_all with a big path with many uncreated directories will stack overflow on Windows. The max path is 32767, which can technically result in ~16383 recursive calls, which will stack overflow the 1mb default stack on Windows.

Meta

rustc --version --verbose:

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-pc-windows-msvc
release: 1.77.1
LLVM version: 17.0.6

Metadata

Metadata

Assignees

Labels

A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions