Skip to content

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

Closed

Description

@ehartford

On Windows x86_64 every program makes three heap allocations at startup that macOS and Linux do not. That breaks the debug-allocator fixtures that pin a program's allocation count:

test/debug_alloc/da_d119_literal_no_heap.w   want allocations=3, Windows: allocations=6
test/debug_alloc/da_no_allocation_reports.w  want allocations=0, Windows: 3

--trace-alloc on win10 (stage1 of main c5fdc17) for da_d119_literal_no_heap.w:

ALLOC 24 2040090329104 0     <- startup, Windows only
ALLOC 8 2040090329152 1      <- startup, Windows only (origin token 1)
ALLOC 48 2040090329184 1     <- startup, Windows only (origin token 1)
ALLOC 24 2040090329104 0     the program's three, as on macOS
ALLOC 64 2040090329184 0
ALLOC 7 2040090329152 0
debug-alloc: leak count=0 allocations=6

macOS and Linux (eric-5090) print allocations=3 for the same program. The wide argv conversion uses rt_mmap, so it is not one of them. Root cause still to find: the three allocations come from the Windows runtime or std startup path before main.

Expected: a program that allocates nothing reports allocations=0 on every host; or, if Windows startup needs heap, it allocates outside the counted heap, as argv does.

Found while removing the debug-alloc lane's Windows skip (#807): 189 of 195 fixtures pass on Windows.

Activity

  1. ehartford commented on Oct 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by 0c16fb6 (stack #2743, battery GREEN on its top ddb68e8: behavior-tests 1949/1949, gate, uat and battery-checks green).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions