uclibc and sqlite

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

uclibc and sqlite

Simon Posnjak
Hi all,

As someone already reported uclibc and sqlite do not play nice together.
I did a bt after a segfault and got:

#0  0x00089f8c in sqlite3OsFileSize (id=0xf0434, pSize=0x0) at
src/os_unix.c:816
#1  0x000bea10 in sqlite3pager_pagecount (pPager=0xf0428) at
src/pager.c:1750
#2  0x000c0062 in sqlite3pager_get (pPager=0xf0428, pgno=1,
ppPage=0x9fffa298) at src/pager.c:2498
#3  0x000a1644 in getPage (pBt=0xf02c8, pgno=1, ppPage=0x9fffa2c0) at
src/btree.c:1115
#4  0x000a1d90 in lockBtree (pBt=0xf02c8) at src/btree.c:1424
#5  0x000a22e6 in sqlite3BtreeBeginTrans (pBt=0xf02c8, wrflag=0) at
src/btree.c:1611
#6  0x000a2032 in lockBtreeWithRetry (pBt=0xf02c8) at src/btree.c:1491
#7  0x000a3220 in sqlite3BtreeCursor (pBt=0xf02c8, iTable=1, wrFlag=0,
xCmp=0, pArg=0x0, ppCur=0x9fffa3cc) at src/btree.c:2152
#8  0x00086b64 in sqlite3InitOne (db=0xf0008, iDb=0,
pzErrMsg=0x9fffa6d6) at src/main.c:204
#9  0x00087030 in sqlite3Init (db=0xf0008, pzErrMsg=0x9fffa6d6) at
src/main.c:347
#10 0x00087162 in sqlite3ReadSchema (pParse=0x9fffa6ce) at src/main.c:387
#11 0x000ab874 in sqlite3LocateTable (pParse=0x9fffa6ce, zName=0xf3bf0
"sqlite_master", zDbase=0x0) at src/build.c:195
#12 0x000c96e8 in prepSelectStmt (pParse=0x9fffa6ce, p=0xf3d88) at
src/select.c:1005
#13 0x000cc4f0 in sqlite3SelectResolve (pParse=0x9fffa6ce, p=0xf3d88,
pOuterNC=0x0) at src/select.c:2334
#14 0x000cc91a in sqlite3Select (pParse=0x9fffa6ce, p=0xf3d88, eDest=1,
iParm=0, pParent=0x0, parentTab=0, pParentAgg=0x0, aff=0x0) at
src/select.c:2548
#15 0x000c3764 in yy_reduce (yypParser=0xf3360, yyruleno=98) at parse.y:329
#16 0x000c55c2 in sqlite3Parser (yyp=0xf3360, yymajor=9, yyminor={z =
0xdc27b "'table'", dyn = 0, n = 7}, pParse=0x9fffa6ce) at parse.c:3303
#17 0x0008e2d8 in sqlite3RunParser (pParse=0x9fffa6ce, zSql=0xdc234
"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL AND
type=='table'",
    pzErrMsg=0x9fffa6ca) at src/tokenize.c:399
#18 0x000884be in sqlite3_prepare (db=0xf0008, zSql=0xdc234 "SELECT
name, type, sql FROM sqlite_master WHERE sql NOT NULL AND
type=='table'", nBytes=-1,
    ppStmt=0x9fffa7bc, pzTail=0x9fffa7c0) at src/main.c:1061
#19 0x0009e8b2 in sqlite3_exec (db=0xf0008, zSql=0xdc234 "SELECT name,
type, sql FROM sqlite_master WHERE sql NOT NULL AND type=='table'",
    xCallback=0x83114 <dump_callback>, pArg=0x9fffe8f5, pzErrMsg=0x0) at
src/legacy.c:56
#20 0x000834ba in run_schema_dump_query (p=0x9fffe8f5, zQuery=0xdc234
"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL AND
type=='table'",
    pzErrMsg=0x0) at src/shell.c:730
#21 0x00083b4a in do_meta_command (zLine=0xf2ca8 ".dump", p=0x9fffe8f5)
at src/shell.c:906
#22 0x00085a16 in process_input (p=0x9fffe8f5, in=0x0) at src/shell.c:1472
#23 0x00086648 in main (argc=2, argv=0x9ffffeb4) at src/shell.c:1789

If we look at the code of sqlite3pager_pagecount in pager.c we find:

int sqlite3pager_pagecount(Pager *pPager){
  i64 n;
  assert( pPager!=0 );
  if( pPager->dbSize>=0 ){
    return pPager->dbSize;
  }
  if( sqlite3OsFileSize(&pPager->fd, &n)!=SQLITE_OK ){
    pPager->errMask |= PAGER_ERR_DISK;
    return 0;
  }
  n /= pPager->pageSize;
  if( !MEMDB && n==PENDING_BYTE/pPager->pageSize ){
    n++;
  }
  if( pPager->state!=PAGER_UNLOCK ){
    pPager->dbSize = n;
  }
  return n;
}

So we call sqlite3OsFileSize with &pPager->fd and &n. But if you look at
the bt you will see that the function was called with &pPager->fd and
NULL (pSize=0x0). How is this possible?

Regards Simon