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

Open 💬 1 comment Opened Jun 27, 2026 by 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

```bash
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_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗