#9431·turso

Trigger execution has no depth bound: a recursive trigger chain overflows the stack and aborts the process

Author: aretta-ci[bot]Created Sep 30, 2026Updated Sep 30, 2026

We tested turso at d6c3bc24dbde2ab3dc577c230f7a43ea184ef192 (main, 2026-09-30; tursodb --version = Turso 0.8.0). We used a release build (cargo build --release --bin tursodb) and only public SQL. The reference is SQLite 3.37.2.

A chain of triggers that fire each other to a moderate depth crashes turso. The process aborts with a stack overflow (SIGABRT). SQLite limits the depth and returns a clean error.

turso has no limit on trigger-execution depth. A trigger chain grows the native stack until the process dies.

Measured, one trigger firing the next, depth = number of triggers in the chain:

depth turso SQLite 3.37.2
872 completes completes
877 fatal runtime error: stack overflow, aborting (exit 134) completes
1000 fatal runtime error: stack overflow, aborting (exit 134) completes
1001 fatal runtime error: stack overflow, aborting (exit 134) too many levels of trigger recursion, statement rolled back

SQLite rolls the statement back and leaves the database untouched. turso kills the whole process, so every client on that process loses its connection. The exact depth where turso crashes depends on the stack size; the missing limit is the defect.

This is trigger-execution depth at run time. It is not parser or expression nesting (compare #8097, #4900).

Reproduction (bash, depth 1000):

bash
d=1000; f=chain.sql; : > $f
for i in $(seq 0 $d); do echo "CREATE TABLE t$i(x);" >> $f; done
for i in $(seq 0 $((d-1))); do echo "CREATE TRIGGER tr$i AFTER INSERT ON t$i BEGIN INSERT INTO t$((i+1)) VALUES(NEW.x); END;" >> $f; done
echo "INSERT INTO t0 VALUES(1); SELECT count(*) FROM t$d;" >> $f
tursodb -q -m list chain.db < chain.sql   # fatal runtime error: stack overflow, aborting
sqlite3 chain-sqlite.db < chain.sql       # prints 1

Expected: a bound on trigger depth, like SQLite's SQLITE_MAX_TRIGGER_DEPTH (1000), that fails the statement with an error instead of aborting the process.