Skip to content

Finish removing CLR local-string dependencies - #12518

Open
simonrozsival wants to merge 5 commits into
dev/simonrozsival/simplify-dso-namefrom
dev/simonrozsival/simplify-create-directory
Open

Finish removing CLR local-string dependencies#12518
simonrozsival wants to merge 5 commits into
dev/simonrozsival/simplify-dso-namefrom
dev/simonrozsival/simplify-create-directory

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • calculate the complete directory path size before copying it
  • use the existing sensible local buffer for common paths and malloc() only for larger values
  • temporarily terminate each path component in place before passing it to mkdir()
  • preserve paths larger than the former inline-storage threshold
  • preserve filesystem errno across conditional heap cleanup
  • remove the final CLR/NativeAOT strings.hh includes after the lower stack layers migrate their consumers

This is the top PR in stack #12519. Together, the stack removes all CLR/NativeAOT uses of the local-string hierarchy and their strings.hh dependencies.

Validation

  • Local native builds intentionally skipped; relying on CI validation

Copilot AI lite review requested due to automatic review settings August 25, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the CLR runtime Util::create_directory() helper to avoid dynamic local-string allocation by using a fixed-size stack buffer and in-place component termination when creating intermediate directories.

Changes:

  • Replaces dynamic_local_string<Constants::SENSIBLE_PATH_MAX> usage with a fixed char buffer sized to Constants::SENSIBLE_PATH_MAX.
  • Adds an explicit length check and returns ENAMETOOLONG when the input path does not fit.
  • Temporarily NUL-terminates each path component in-place before calling mkdir().
Show a summary per file
File Description
src/native/clr/runtime-base/util.cc Switch create_directory() to a fixed stack buffer, add bounded-length rejection, and use in-place component termination before mkdir().

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/native/clr/runtime-base/util.cc Outdated
@simonrozsival simonrozsival added the drop-libcpp Work to remove the libc++ dependency from Android NativeAOT label Aug 25, 2026
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-create-directory branch from 074222a to 7280623 Compare August 25, 2026 15:10
@simonrozsival
simonrozsival changed the base branch from main to dev/simonrozsival/simplify-dso-name August 25, 2026 15:10
@simonrozsival simonrozsival changed the title Use a fixed buffer to create directories Finish removing CLR local-string dependencies Aug 25, 2026
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-create-directory branch from 7280623 to 98cc195 Compare August 25, 2026 15:39
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-create-directory branch from 98cc195 to 886d2a5 Compare August 25, 2026 15:43
simonrozsival and others added 5 commits August 25, 2026 17:59
Replace the resizable local string in Util::create_directory with a checked mutable path buffer and report ENAMETOOLONG when it cannot fit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop scanning once the fixed create-directory buffer capacity is reached.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The stacked fixed-buffer migrations remove every remaining CLR and NativeAOT consumer of strings.hh, so drop the final includes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the former dynamic local string behavior with malloc/free instead of imposing SENSIBLE_PATH_MAX as a path limit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the sensible local buffer for common paths and allocate only when the complete path exceeds it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/simplify-create-directory branch from 886d2a5 to 1104485 Compare August 25, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drop-libcpp Work to remove the libc++ dependency from Android NativeAOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants