Skip to content

Restricted command sandbox can cause false asyncio thread wakeup hangs with sqlite3/aiosqlite #30352

Open

Description

@Tomorrowdawn

What version of Codex CLI is running?

0.142.3

What subscription do you have?

pro

Which model were you using?

gpt-5.5 medium

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

Win Terminal

Codex doctor report

What issue are you seeing?

In a Codex managed filesystem sandbox, Python programs combining asyncio, a background
threading.Thread, sqlite3, and loop.call_soon_threadsafe(...) appeared to hang indefinitely. The same
commands succeeded immediately after switching the session to full access / unrestricted execution.

This produced a false diagnosis that Python 3.14 + aiosqlite was broken, and led to unnecessary dependency/
backend investigation.

What steps can reproduce the bug?

Minimal Reproducer

timeout 10s python -c $'import asyncio, sqlite3, threading, sys
print(sys.version.split()[0], flush=True)
async def main():
    loop = asyncio.get_running_loop()
    fut = loop.create_future()
    def worker():
        print("worker-start", flush=True)
        conn = sqlite3.connect(":memory:")
        print("worker-connect", flush=True)
        row = conn.execute("select 1").fetchone()[0]
        print("worker-execute", flush=True)
        loop.call_soon_threadsafe(fut.set_result, row)
        print("worker-scheduled", flush=True)
    threading.Thread(target=worker).start()
    print(await fut, flush=True)
asyncio.run(main())'

## Observed In Restricted Sandbox

The command timed out after printing:

3.13.9
worker-start
worker-connect
worker-execute
worker-scheduled

The main asyncio event loop did not resume after loop.call_soon_threadsafe(...).

aiosqlite.connect(":memory:") showed the same behavior because aiosqlite uses a worker thread and completes
awaiters via the event loop.

## Observed In Full Access

The same reproducer completed immediately:

3.13.9
worker-start
worker-connect
worker-execute
worker-scheduled
1

Also verified:

timeout 10s .venv/bin/python -c '... aiosqlite connect/execute/close ...'
timeout 15s .venv/bin/python -c '... Store.open(":memory:"); store.migrate() ...'
timeout 120s .venv/bin/python -m pytest apps/yuubot/tests/
test_daemon_resource_crud.py::test_create_llm_backend_preserves_model_configs -q

The targeted pytest passed:

1 passed in 0.09s

### What is the expected behavior?

## Expected Behavior

The restricted sandbox should not change asyncio thread wakeup behavior, or Codex should clearly warn that
this class of reproducer may be invalid under sandboxing.

### Additional information

_No response_

Activity

  1. added
    bug
    on Jun 27, 2026
  2. added
    CLI
    sandbox
    on Jun 27, 2026
  3. github-actions commented on Jun 27, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

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

    CLIbugsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions