openai / openai/codex

Global-state atomic writes leak tmp files truncated at exactly 512 KiB

Open
#44,999 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Environment

  • Codex app version: 26.903.71938 (macOS, Darwin 25.6.0)

Observed

~/.codex/ accumulates orphaned temp files named ..codex-global-state.json.tmp-<epoch_ms>-<uuid> — 17 of them between Jun 28 and Aug 8 2026, and every single one is exactly 524,288 bytes (512 KiB), truncated mid-JSON (e.g. tail ends ...{"activePermissionProfile":n).

The live .codex-global-state.json is currently ~2.6 MB, so it exceeds the apparent cap by ~5x.

Hypothesis

The atomic-write path for global state appears to hit a fixed 512 KiB write/buffer limit on the temp file. Once the serialized state exceeds 512 KiB, the tmp write truncates or aborts and the file is never renamed or cleaned up — leaving one orphaned 512 KiB file per failed write.

Impact

  • Cosmetic disk litter in ~/.codex/ (17 files ≈ 8.7 MB so far, growing over time)
  • More concerning: it suggests global-state writes are failing or being abandoned once state grows past 512 KiB — worth confirming the live .codex-global-state.json write path does not share the same cap.

Repro

Long-running Codex app usage until .codex-global-state.json exceeds 512 KiB; tmp files appear without any user action.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Rust atomic-write path for global state and reproduce the issue with .codex-global-state.json larger than 512 KiB. Verify whether the live state write is capped, ensure failed temporary writes are cleaned up, and confirm successful writes leave no orphaned tmp files.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.