First, it doesn't happen if I run the code in the main thread, only when I spawn a thread for it--even though it's the only thread that touches sqlite, and regardless of whether I compile with --enable-threadsafe or not. It always happens at the same place (here, on the sixth CREATE TABLE statement), though the location seems to depend on the amount of cumulative text in the sqlite3_exec() calls. You can reorder them, and it usually crashes around the sixth statement.
Here's the stack trace:
#0 0x0000dc50 in balance_shallower (pPage=0x2804c30) at ../src/btree.c:3283
#1 0x0000dbc4 in balance_nonroot (pPage=0xd) at ../src/btree.c:3260
#2 0x0000debc in balance_deeper (pPage=0x2804c30) at ../src/btree.c:3395
#3 0x0000df14 in balance (pPage=0x2804c30) at ../src/btree.c:3408
#4 0x0000e198 in sqlite3BtreeInsert (pCur=0x55e3a0, pKey=0x0, nKey=17221830959, pData=0x55e490, nData=201) at ../src/btree.c:3521
#5 0x0003398c in sqlite3VdbeExec (p=0x2808200) at ../src/vdbe.c:3053
#6 0x0001f2d0 in sqlite3_step (pStmt=0x55e340) at ../src/vdbeapi.c:159
#7 0x0000a36c in sqlite3_exec (db=0xc9, zSql=0x280ac40 "", xCallback=0, pArg=0x40dbc, pzErrMsg=0x0) at ../src/legacy.c:79
and here's the code (XCode 1.2 project):
http://www.opaque.net/~dave/dbtest.tgz
Can another OS X user give this a try, see if it crashes for you? Any ideas what's going on?
If you've got a fix for me I'll send you a swank Panic brand t-shirt. If it's something really obvious and stupid I've done, two. :)
Thanks, -Dave