Skip to content

fix(windows): increase stack size to resolve runtime overflow#2621

Merged
killf merged 1 commit intomainfrom
fix/windows-stack-size
Mar 3, 2026
Merged

fix(windows): increase stack size to resolve runtime overflow#2621
killf merged 1 commit intomainfrom
fix/windows-stack-size

Conversation

@killf
Copy link
Copy Markdown

@killf killf commented Mar 3, 2026

Problem

Running cargo run --bin zeroclaw on Windows fails with:

thread 'main' has overflowed its stack
error: process didn't exit successfully (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

Root Cause

Windows platforms have a default stack size (1-2MB) that is insufficient for:

  • 133 JsonSchema derives in src/config/schema.rs
  • Large trait implementations generated by schemars library at compile time

Solution

Increase stack size to 8MB for Windows targets in .cargo/config.toml:

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "link-args=/STACK:8388608"]

[target.aarch64-pc-windows-msvc]
rustflags = ["-C", "link-args=/STACK:8388608"]

Changes

  • ✅ Add 8MB stack size for x86_64-pc-windows-msvc
  • ✅ Add 8MB stack size for aarch64-pc-windows-msvc
  • ✅ Remove unused ErrorKind import in src/update.rs

Testing

cargo run --bin zeroclaw -- --version  # ✅ Works
cargo run --bin zeroclaw -- status      # ✅ Works

Fixes: Windows runtime stack overflow on program startup


Supersedes #2591 by @killf

This PR carries forward the same Windows stack size fix from the original PR.

Summary by CodeRabbit

  • Chores
    • Updated Windows MSVC platform configuration with enhanced stack size allocation for improved stability and compatibility on Windows x86_64 and ARM64 architectures.

Windows platforms have a default stack size (1-2MB) that is too small
for the heavy JsonSchema derives in config/schema.rs (133 derives).
This causes "thread 'main' has overflowed its stack" on startup.

Changes:
- Increase stack size to 8MB for x86_64-pc-windows-msvc
- Increase stack size to 8MB for aarch64-pc-windows-msvc
- Remove unused ErrorKind import in src/update.rs

Fixes: cargo run --bin zeroclaw stack overflow on Windows
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2026

PR intake checks found warnings (non-blocking)

Fast safe checks found advisory issues. CI lint/test/build gates still enforce merge quality.

  • Missing required PR template sections: ## Summary, ## Validation Evidence (required), ## Security Impact (required), ## Privacy and Data Hygiene (required), ## Rollback Plan (required)
  • Incomplete required PR template fields: summary problem, summary why it matters, summary what changed, validation commands, security risk/mitigation, privacy status, rollback plan
  • Missing Linear issue key reference (RMN-<id>, CDV-<id>, or COM-<id>) in PR title/body (recommended for traceability, non-blocking).

Action items:

  1. Complete required PR template sections/fields.
  2. (Recommended) Link this PR to one active Linear issue key (RMN-xxx/CDV-xxx/COM-xxx) for traceability.
  3. Remove tabs, trailing whitespace, and merge conflict markers from added lines.
  4. Re-run local checks before pushing:
    • ./scripts/ci/rust_quality_gate.sh
    • ./scripts/ci/rust_strict_delta_gate.sh
    • ./scripts/ci/docs_quality_gate.sh

Detected Linear keys: none

Run logs: https://github.com/zeroclaw-labs/zeroclaw/actions/runs/22615081314

Detected blocking line issues (sample):

  • none

Detected advisory line issues (sample):

  • none

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 3, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools', 'path_filters', 'review_instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

Adds Windows MSVC target configurations to .cargo/config.toml with increased stack size settings via rustflags for both x86_64 and aarch64 architectures, placing them alongside existing platform-specific target configurations.

Changes

Cohort / File(s) Summary
Cargo Configuration
.cargo/config.toml
Added Windows MSVC target configurations (x86_64-pc-windows-msvc and aarch64-pc-windows-msvc) with rustflags to increase stack size to 8388608 bytes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

bug, size: XS, risk: medium, config: core

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing most required sections from the repository template (Label Snapshot, Change Metadata, Linked Issue, Validation Evidence, Security Impact, etc.). Complete the PR description by filling in all required template sections including labels, change type, linked issues, validation evidence, security/privacy checks, and rollback plan.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: increasing Windows stack size to fix a runtime overflow issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/windows-stack-size

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size: XS Auto size: <=80 non-doc changed lines. risk: low Auto risk: docs/chore-only paths. trusted contributor Contributor with 5+ merged PRs. labels Mar 3, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.cargo/config.toml (1)

28-33: Consider adding a Windows CI smoke test for regression protection.

A minimal Windows job running cargo run --bin zeroclaw -- --version would help ensure this stack-overflow fix stays covered.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.cargo/config.toml around lines 28 - 33, Add a minimal Windows CI smoke test
to protect the increased Windows stack-size change under the
[target.x86_64-pc-windows-msvc] and [target.aarch64-pc-windows-msvc] rustflags:
create a CI job that runs on a Windows runner and executes cargo run --bin
zeroclaw -- --version (or cargo build && cargo run --bin zeroclaw -- --version)
to verify the binary starts successfully; ensure the job is included in the
matrix or workflow that runs on PRs so future regressions to .cargo/config.toml
(the rustflags /STACK change) get caught automatically.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.cargo/config.toml:
- Around line 28-33: Add a minimal Windows CI smoke test to protect the
increased Windows stack-size change under the [target.x86_64-pc-windows-msvc]
and [target.aarch64-pc-windows-msvc] rustflags: create a CI job that runs on a
Windows runner and executes cargo run --bin zeroclaw -- --version (or cargo
build && cargo run --bin zeroclaw -- --version) to verify the binary starts
successfully; ensure the job is included in the matrix or workflow that runs on
PRs so future regressions to .cargo/config.toml (the rustflags /STACK change)
get caught automatically.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49efa16 and 1e4fc3c.

📒 Files selected for processing (1)
  • .cargo/config.toml

@killf killf merged commit 4059640 into main Mar 3, 2026
46 checks passed
@theonlyhennygod theonlyhennygod deleted the fix/windows-stack-size branch March 12, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low Auto risk: docs/chore-only paths. size: XS Auto size: <=80 non-doc changed lines. trusted contributor Contributor with 5+ merged PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant