[BUG] claude code crashes when executing `sqlite` CLI command
Resolved 💬 4 comments Opened Jul 16, 2025 by benswift Closed Jan 9, 2026
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.53 (Claude Code)
- Operating System: Ubuntu 24.04 (Linux 6.8.0-57-generic)
- Terminal: Multiple tested (gnome-terminal, alacritty)
Bug Description
Claude Code crashes with std::bad_alloc error when executing any sqlite3 CLI command, even for trivial queries on tiny databases. The crash occurs immediately upon running the command, regardless of query complexity or result size.
Steps to Reproduce
- Create a minimal test database by running this script:
#!/bin/bash
# Create a minimal SQLite database for testing
cat > /tmp/create_test_db.py << 'EOF'
import sqlite3
db_path = "/tmp/test_claude_crash.db"
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)")
cursor.execute("INSERT INTO test (name) VALUES ('hello')")
cursor.execute("INSERT INTO test (name) VALUES ('world')")
conn.commit()
conn.close()
print(f"Created test database: {db_path}")
EOF
python3 /tmp/create_test_db.py
- Start Claude Code:
claude
- Inside Claude Code, run:
sqlite3 /tmp/test_claude_crash.db 'SELECT * FROM test;'
Expected Behavior
The query should return two rows:
1|hello
2|world
Actual Behavior
Claude Code immediately crashes with:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
The session terminates with exit code 134.
Additional Context
- The same sqlite3 command works perfectly when run outside of Claude Code
- The test database is only 8KB with 2 rows of data
- Using mise-provided sqlite3 version 3.48.0 (
/home/ben/.local/share/mise/installs/sqlite/3.48.0/bin/sqlite3) - The crash occurs even with the simplest possible queries (e.g.,
SELECT 1;)
Workarounds that prevent the crash:
- Redirect sqlite3 output to a file:
sqlite3 /tmp/test_claude_crash.db 'SELECT * FROM test;' > results.txt - Use Python's sqlite3 module instead of the CLI:
import sqlite3
conn = sqlite3.connect('/tmp/test_claude_crash.db')
for row in conn.execute("SELECT * FROM test"):
print(row)
conn.close()
This appears to be an issue with Claude Code's subprocess handling of sqlite3 CLI output, not with the database or query itself.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗