Skip to content

fix: tolerate temp dir cleanup failures on Windows#688

Draft
fabiomadge wants to merge 1 commit intostrata-org:mainfrom
fabiomadge:fix/no-get-value-in-smt-file
Draft

fix: tolerate temp dir cleanup failures on Windows#688
fabiomadge wants to merge 1 commit intostrata-org:mainfrom
fabiomadge:fix/no-get-value-in-smt-file

Conversation

@fabiomadge
Copy link
Copy Markdown
Contributor

@fabiomadge fabiomadge commented Mar 27, 2026

On Windows, z3 may exit with a non-zero code (e.g., from get-value after unsat), and the OS may not release the SMT file handle immediately. This caused IO.FS.withTempDir's cleanup to throw, crashing the process before diagnostics were emitted.

Replace withTempDir with manual createTempDir + removeDirAll wrapped in try/catch.

Root cause: (get-value) is emitted unconditionally after (check-sat) in the file-based solver. When z3 returns unsat, (get-value) errors with "model is not available" and z3 exits with code 1. The SMT file handle may remain locked briefly on Windows, causing the temp directory cleanup to fail.

@fabiomadge fabiomadge requested a review from a team March 27, 2026 15:50
@fabiomadge fabiomadge marked this pull request as draft March 27, 2026 15:51
@fabiomadge fabiomadge force-pushed the fix/no-get-value-in-smt-file branch 2 times, most recently from 5ced8d4 to 5b13503 Compare March 31, 2026 02:07
@fabiomadge fabiomadge changed the title fix: don't emit get-value in SMT file fix: tolerate temp dir cleanup failures on Windows Mar 31, 2026
Two fixes for Windows z3 compatibility:

1. Replace withTempDir with manual createTempDir + removeDirAll in
   try/catch, since z3 may exit non-zero and the OS may not release
   the SMT file handle immediately.

2. Don't emit (get-value) in SMT files. When z3 returns unsat, the
   subsequent (get-value) causes 'model is not available' error and
   z3 exits with code 1. This loses counterexample model values but
   avoids the error entirely.

Both fixes are needed because the z3 exit code 1 from (get-value)
triggers the temp dir cleanup failure on Windows.
@fabiomadge fabiomadge force-pushed the fix/no-get-value-in-smt-file branch from 5b13503 to 5e8a582 Compare March 31, 2026 06:34
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.

1 participant