Skip to content

Runtime (Windows): startup sets PWD without allocating, so a program that allocates nothing reports allocations=0 (#2722) - #2738

Merged
ehartford merged 1 commit into
fix-2647from
fix-2722
Oct 26, 2026
Merged

ehartford merged 1 commit into
fix-2647from
fix-2722

Conversation

@ehartford

@ehartford ehartford commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

rt_store_args sets PWD from the real directory at startup (#1082). It
went through with_str_from_cstr and win_setenv, which allocate a 24-byte
str and the UTF-16 name and value (8 and 48 bytes for a 23-character
cwd: the trace on win10 showed exactly those three before main), so every
Windows program counted three heap allocations the other hosts do not
make: da_d119_literal_no_heap saw allocations=6 for 3, and
da_no_allocation_reports 3 for 0. The startup now converts the cwd into a
stack buffer, as the realpath beside it does, and calls
SetEnvironmentVariableW directly.

Tests: test/debug_alloc/da_d119_literal_no_heap.w and
da_no_allocation_reports.w, run on Windows once the debug-alloc lane runs
there (#807).

Closes #2722

@ehartford
ehartford added this pull request to stack #2743 October 26, 2026 04:07
@ehartford ehartford changed the title fix 2722 Runtime (Windows): startup sets PWD without allocating, so a program that allocates nothing reports allocations=0 (#2722) Oct 26, 2026
…that allocates nothing reports allocations=0 (#2722)

rt_store_args sets PWD from the real directory at startup (#1082). It
went through with_str_from_cstr and win_setenv, which allocate a 24-byte
str and the UTF-16 name and value (8 and 48 bytes for a 23-character
cwd: the trace on win10 showed exactly those three before main), so every
Windows program counted three heap allocations the other hosts do not
make: da_d119_literal_no_heap saw allocations=6 for 3, and
da_no_allocation_reports 3 for 0. The startup now converts the cwd into a
stack buffer, as the realpath beside it does, and calls
SetEnvironmentVariableW directly.

Tests: test/debug_alloc/da_d119_literal_no_heap.w and
da_no_allocation_reports.w, run on Windows once the debug-alloc lane runs
there (#807).
@ehartford
ehartford marked this pull request as ready for review October 26, 2026 04:31
@ehartford
ehartford merged commit 0c16fb6 into main Oct 26, 2026
@ehartford
ehartford deleted the fix-2722 branch October 26, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: three heap allocations before main that other hosts don't make (debug-alloc counts differ)

1 participant