Skip to content

[Windows 26.924] Desktop app fails to start after app-server restart due to lingering SQLite SHM mapping #49605

Open

Description

@cab79

What version of the Codex App are you using (From “About Codex” dialog)?

26.924.2738.0

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows 11 Version 24H2 (Build 26100.9457)

What issue are you seeing?

Since updating to Windows desktop version 26.924.2738.0, the ChatGPT/Codex
desktop app fails during startup when using the Windows-native Codex runtime.

The visible error is:

failed to initialize sqlite state runtime under C:\Users<user>.codex
failed to initialize state runtime at C:\Users<user>.codex

I investigated this with Process Monitor and reproducible process tests.

The failure appears to be a race during app-server startup/restart rather than
corruption of my .codex data.

Observed sequence:

  1. ChatGPT starts codex.exe.
  2. Approximately 1 second later, the desktop app terminates that codex.exe
    process and starts a replacement process.
  3. On this machine, Cisco Secure Endpoint substantially delays teardown of the
    terminated codex.exe process. The terminated process remains present for
    approximately 15-16 seconds.
  4. During teardown, the original process still has memories_1.sqlite-shm
    memory-mapped.
  5. The replacement codex.exe starts approximately 2-3 seconds after the first
    process is terminated.
  6. SQLite attempts to initialise/reset its shared-memory state while the old
    mapping still exists.
  7. Windows returns USER MAPPED FILE and Codex exits with the
    "failed to initialize sqlite state runtime" error.

This is reproducible independently of my existing Codex data.

A completely empty Codex home works on its first launch because the state
databases do not yet exist. Once the databases have been created, the same
fresh Codex home can reproduce the failure on a subsequent launch.

I can also reproduce the exact failure outside the desktop startup sequence by:

  • starting codex.exe;
  • terminating it approximately 1 second later;
  • starting another instance approximately 2.6 seconds later.

If I instead wait approximately 20 seconds for the first process to disappear
fully before starting the replacement, the failure does not occur.

Cisco Secure Endpoint appears to expose the race by greatly extending process
teardown time. I am not claiming that Cisco Secure Endpoint itself is the
underlying Codex defect. The desktop app appears to assume that the previous
app-server's SQLite mappings have already been released before starting the
replacement process.

Importantly, switching the ChatGPT desktop Agent Environment from Windows
native to WSL avoids the problem. WSL mode survives repeated full
quit/relaunch cycles successfully, while Windows-native mode continues to
reproduce the SQLite initialisation failure.

This further suggests that the problem is specific to the Windows-native Codex
runtime/process lifecycle rather than corruption of my account, sessions or
Codex home.

What steps can reproduce the bug?

  1. Use ChatGPT/Codex Desktop 26.924.2738.0 on Windows.
  2. Select the Windows-native Agent Environment.
  3. Use a Codex home which already contains its normal SQLite state databases.
  4. Fully quit and relaunch the desktop application.
  5. During startup, observe that the first codex.exe app-server starts and is
    then terminated by the desktop app.
  6. A replacement codex.exe starts approximately 2-3 seconds later.
  7. If teardown of the original process is still occurring, the replacement
    process fails to initialise the SQLite state runtime.

Observed result:

failed to initialize sqlite state runtime under C:\Users<user>.codex

More direct reproduction:

  1. Start codex.exe against a Codex home containing the generated state DBs.
  2. Terminate that process approximately 1 second after startup.
  3. Start a second instance approximately 2.6 seconds later.
  4. The second instance reproduces the same SQLite initialisation failure.
  5. Repeat the test but wait approximately 20 seconds before starting instance 2.
  6. The second instance starts successfully.

On this machine, a terminated codex.exe takes approximately 15.6 seconds to
fully disappear, compared with tens of milliseconds for ordinary processes.
Process Monitor shows extensive reads of the codex.exe image during that
teardown. Cisco Secure Endpoint is installed and active.

Control test:

  1. Switch ChatGPT Desktop Agent Environment from Windows native to WSL.
  2. Fully quit the application.
  3. Relaunch repeatedly.
  4. WSL mode starts successfully across repeated relaunches and does not produce
    the SQLite initialisation error.

What is the expected behavior?

The desktop app should successfully restart/relaunch its app-server even if
termination of the previous codex.exe process takes longer than usual.

In particular, it should not initialise/reset a SQLite shared-memory file while
the previous app-server process still has that file mapped.

Possible fixes might include:

  • waiting for the previous process to have fully exited before launching the
    replacement;
  • retrying SQLite initialisation when ERROR_USER_MAPPED_FILE occurs;
  • delaying/retrying WAL/SHM reset while stale mappings remain;
  • avoiding overlapping access to the state-runtime SHM file during app-server
    restart.

The Windows-native runtime should behave robustly even when endpoint-security
software makes process teardown slower than normal.

Additional information

Troubleshooting already performed:

  • Reset/reinstalled the desktop app.
  • Created a completely fresh .codex directory.
  • Tested old and freshly-created state databases.
  • Recreated/moved memories_1.sqlite.
  • Disabled plugins.
  • Disabled memory-related feature flags.
  • Checked SQLite integrity.
  • Compared old and new Codex homes.
  • Checked filesystem permissions/ownership.
  • Reproduced the process timing independently.
  • Tested WSL Agent Environment.

None of the Windows-native configuration changes provides a durable fix.

The existing SQLite databases and previous session data pass integrity checks
and do not appear to be the cause.

Importantly, a completely fresh Codex home can also develop the problem once
its databases have been created.

WSL mode works reliably on the same machine and survives repeated relaunches.

The issue began after the update to 26.924. The previous 26.917 build did not
show this behaviour on this PC.

There are also other recent Windows 26.924 reports where a fresh Codex home
works initially but subsequent launches fail, although I have not found another
public report that isolates the same Cisco Secure Endpoint / process-teardown /
SQLite SHM mechanism.

I can provide, if useful:

  • Process Monitor traces showing both codex.exe processes and the
    USER MAPPED FILE failure;
  • precise PID/start/termination timestamps;
  • a small reproduction script demonstrating the timing race;
  • relevant desktop/Codex logs.

I have deliberately not attached my complete .codex directory because it
contains account/session data.

Activity

  1. added
    app
    on Sep 30, 2026
  2. added
    bug
    windows-os
    app-server
    on Sep 30, 2026
  3. gunwookim0221 commented on Oct 27, 2026

    @gunwookim0221

    I reproduced what appears to be the same failure outside AO/Orchestrator using a diagnostic build of Codex rust-v0.164.0.

    Environment:

    • Windows 11
    • normal user context: DESKTOP-H6PQG3O\smani
    • Medium integrity
    • real/default Codex home: C:\Users\smani\.codex

    The diagnostic build was instrumented only to expose the state-runtime initialization stage and underlying SQLite error chain.

    The failure reproduced as:

    stage=open_memories_db
    db_path=C:\Users\smani\.codex\memories_1.sqlite
    sqlite_code=1546
    disk I/O error
    

    SQLite extended result code 1546 corresponds to SQLITE_IOERR_TRUNCATE.

    The top-level Codex failure was the usual:

    failed to initialize sqlite state runtime under C:\Users\smani\.codex
    failed to initialize state runtime at C:\Users\smani\.codex
    

    Additional observations:

    • The databases previously passed SQLite integrity/quick checks.
    • No database repair/reset was performed.
    • WAL/SHM files were not deleted.
    • The failure reproduces outside AO, so AO does not appear to be required to trigger it.
    • Rebooting Windows temporarily restores Codex/app-server startup, but the failure later recurs after continued use.
    • This pattern seems consistent with the lingering/mapped SQLite SHM behavior described in this issue.

    I have not yet captured the native Windows error underneath SQLITE_IOERR_TRUNCATE, so I cannot confirm ERROR_USER_MAPPED_FILE (1224) specifically. However, the failing database/stage and SQLite extended code are now confirmed.

    Diagnostic Codex baseline:
    rust-v0.164.0
    commit:
    6aaac694803004a63c6f393d153c96d22521a6b9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    appapp-serverbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions