Skip to content

fix(cli): wait for the hash-seed re-exec on Windows instead of os.execvpe (#3799) - #3816

Closed
sinangumuskabak-sys wants to merge 1 commit into
Graphify-Labs:v8from
sinangumuskabak-sys:fix/windows-hashseed-reexec-3799
Closed

sinangumuskabak-sys wants to merge 1 commit into
Graphify-Labs:v8from
sinangumuskabak-sys:fix/windows-hashseed-reexec-3799

Conversation

@sinangumuskabak-sys

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #3799.

On Windows os.exec* does not replace the process: CPython spawns a new one and the calling process exits immediately. So update / extract / cluster-only / label (the commands that pin PYTHONHASHSEED via _pin_hash_seed_if_needed) returned before graph.json was written, and the exiting parent intermittently died with an access violation (exit 139 / 0xC0000005).

This PR moves the re-exec into a small _reexec(argv, env) helper:

  • POSIX: unchanged, a real os.execvpe.
  • Windows: runs the child with subprocess.run, waits for it, and exits with the child's return code (as suggested in the issue).

The existing OSError fallback (keep running without the pin) still applies to both branches.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

How was this tested?

Windows 11, Python 3.12, graphify 0.9.67 (pip graphifyy), small TSX corpus, PYTHONHASHSEED unset:

before: python -m graphify update .   -> 6/6 runs exit 139 (Windows fatal exception: access violation in os.execvpe)
after:  python -m graphify update .   -> 8/8 runs exit 0, graph.json present when the command returns

pytest tests/test_pin_hash_seed.py      -> 10 passed
full suite, before vs after this change (same machine): identical failure set, except
  tests/test_pin_hash_seed.py::test_update_still_runs_end_to_end_with_hashseed_unset
  which fails on Windows before this change and passes after it.
  (The remaining failures are pre-existing on Windows / missing optional extras and
  unrelated to this change.)

Test changes: the subprocess probes now stub _reexec instead of os.execvpe (so on a Windows CI runner they never spawn a real child), and two unit tests cover the POSIX execvpe branch and the Windows wait-and-propagate branch.

Graphify-specific checklist

  • I added or updated tests for behavior changes.
  • I updated documentation or confirmed that no documentation is needed.
  • I updated generated skill artifacts when changing their source fragments. (none touched)
  • I considered compatibility across supported Python versions.
  • I confirmed that no API keys, generated graph data, or local-only files are included.

🤖 Generated with Claude Code

…cvpe (Graphify-Labs#3799)

On Windows os.exec* does not replace the process: CPython spawns a new one
and the caller exits at once, so update/extract/cluster-only/label returned
before graph.json was written, and the exiting parent intermittently died
with an access violation (exit 139). Run the child with subprocess, wait for
it and propagate its exit status there; POSIX keeps the real os.execvpe.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. 1 change(s) tested, no difference found (not proven).


Graphify review — findings

Fixes hash-seed re-exec on Windows, where os.exec* spawns a detached child and returns immediately so the parent exits (sometimes with an access violation) before the work finishes. Routes the re-exec through a new _reexec helper that keeps the real os.execvpe on POSIX but, on Windows, runs the child synchronously via subprocess.run and exits with its return code.

No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 218 functions depend on the 34 functions this change touches.

Health — this change adds coupling hotspots:

  • new: main() — 98 callers, 3 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: test_poisoned_manifest_is_healed() — 0 callers, 6 callees

Verification — 218 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 218 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

22 of 300 test file(s) selected (7%) via static blast radius.

  • tests/test_affected_cli.py — impact
  • tests/test_agents_platform.py — impact
  • tests/test_codebuddy.py — impact
  • tests/test_devin.py — impact
  • tests/test_explain_cli.py — impact
  • tests/test_extract_cli.py — impact
  • tests/test_global_add_tag_inference.py — impact
  • tests/test_god_nodes_cli.py — impact
  • tests/test_hollow_chunks_arm_shrink_guard.py — impact
  • tests/test_incomplete_build_guard.py — impact
  • tests/test_install.py — impact
  • tests/test_install_references.py — impact
  • tests/test_install_version_warning.py — impact
  • tests/test_merge_chunks_validation.py — impact
  • tests/test_multigraph_diagnostics.py — impact
  • tests/test_no_dedup_flag.py — impact
  • tests/test_path_cli.py — impact
  • tests/test_pin_hash_seed.py — impact, changed-test
  • tests/test_query_cli.py — impact
  • tests/test_query_induced_edges.py — impact
  • tests/test_skill_version_warning.py — impact
  • tests/test_unverified_semantic_shrink.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

No difference found (not proven): No behavior difference found in \_pin\_hash\_seed\_if\_needed (not a proof).

The verifier ran both versions of \_pin\_hash\_seed\_if\_needed on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

· 1 grounded finding(s) anchored inline below; 2 more finding(s) on lines outside this diff (see the check run).

Comment thread graphify/__main__.py
os.execvpe(argv[0], argv, env)


def main() -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Health regression — main()

98 callers depend on it (afferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

safishamsi added a commit that referenced this pull request Sep 25, 2026
Windows hash-seed re-exec wait (#3816/#3799), Terraform secret-named
variable-default/output redaction (#3817), COBOL fixed-format
sequence-number detection (#3813) and PERFORM...THRU both-endpoint
linking (#3814), and gate the GRAPH_REPORT undocumented-components
reason on a real semantic layer (#3828/#3801).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.68 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @sinangumuskabak-sys! Completes the 0.9.67 Windows re-exec fix (spawn-and-wait + exit-code propagation).

Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.68

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.

[Bug]: Windows: _pin_hash_seed_if_needed re-exec returns before the command finishes, or segfaults

2 participants