Re: [sqlite] memory handling problems in 3.710 - 3.7.11

31 views
Skip to first unread message

Richard Hipp

unread,
Mar 26, 2012, 8:20:22 AM3/26/12
to General Discussion of SQLite Database, g...@debian.hu
On Sun, Mar 25, 2012 at 9:32 PM, Laszlo Boszormenyi <g...@debian.hu> wrote:

> Hi,
>
> On Debian and amd64 architecture SQLite3 has a severe problem. If I just
> start it, I can create a simple table like "create table a(b int);".
> However when I set "export MALLOC_CHECK_=1" then the mentioned table
> creation reports:
> *** glibc detected *** sqlite3: free(): invalid pointer:
> 0x00007fba85c30560 ***
>

Usually, this kind of thing is an indication that your application (not
SQLite) is corrupting the heap, and SQLite just happen to have the
misfortune of being the first to bump into that corruption.

Have you tried running your application using valgrind?


>
> If MALLOC_CHECK_ set to 2 then it just aborts with a zero length
> database and a database-journal being 512 bytes long.
> gdb reports the following related backtrace:
> #2 0x00007ffff75ddae0 in malloc_printerr (action=2, str=0x7ffff76b186a
> "free(): invalid pointer", ptr=0x2399) at malloc.c:6288
> #3 0x00007ffff7b4d070 in sqlite3_free (p=0x555555791e10) at
> sqlite3.c:19059
> #4 sqlite3_free (p=0x555555791e10) at sqlite3.c:19051
> #5 0x00007ffff7bb1312 in sqlite3VdbeExec (p=0x555555793e10) at
> sqlite3.c:69790
> #6 0x00007ffff7b9a731 in sqlite3Step (p=0x555555793e10) at sqlite3.c:63163
> #7 sqlite3_step (pStmt=0x555555793e10) at sqlite3.c:63236
>
> I tried to set a breakpoint on sqlite3VdbeExec and see what's going on.
> Then p is (Vdbe *) 0x5555557950c0 and its db part (print *p->db):
> {pVfs = 0x7ffff7dda2a0, pVdbe = 0x5555557950c0, pDfltColl =
> 0x5555557772b0, mutex = 0x0, aDb = 0x555555780c80, nDb = 2,
> flags = 1744833024, lastRowid = 0, openFlags = 6, errCode = 0, errMask =
> 255, autoCommit = 1 '\001', temp_store = 0 '\000',
> mallocFailed = 0 '\000', dfltLockMode = 0 '\000', nextAutovac = -1 'ÿ',
> suppressErr = 0 '\000', vtabOnConflict = 0 '\000',
> isTransactionSavepoint = 0 '\000', nextPagesize = 0, magic = 2687084183,
> nChange = 0, nTotalChange = 0, aLimit = {1000000000, 1000000000,
> 2000, 1000, 500, 25000, 127, 10, 50000, 999, 1000}, init = {newTnum =
> 1, iDb = 0 '\000', busy = 1 '\001', orphanTrigger = 0 '\000'},
> activeVdbeCnt = 1, writeVdbeCnt = 0, vdbeExecCnt = 1, nExtension = 0,
> aExtension = 0x0, xTrace = 0, pTraceArg = 0x0, xProfile = 0,
> pProfileArg = 0x0, pCommitArg = 0x0, xCommitCallback = 0, pRollbackArg =
> 0x0, xRollbackCallback = 0, pUpdateArg = 0x0,
> xUpdateCallback = 0, xWalCallback = 0x7ffff7bbbc70
> <sqlite3WalDefaultHook>, pWalArg = 0x3e8, xCollNeeded = 0, xCollNeeded16 =
> 0,
> pCollNeededArg = 0x0, pErr = 0x555555777380, zErrMsg = 0x0, zErrMsg16 =
> 0x0, u1 = {isInterrupted = 0, notUsed1 = 0}, lookaside = {
> sz = 128, bEnabled = 0 '\000', bMalloced = 1 '\001', nOut = 0, mxOut =
> 0, anStat = {0, 0, 0}, pFree = 0x555555791ac0,
> pStart = 0x555555782140, pEnd = 0x555555791b40}, xAuth = 0, pAuthArg =
> 0x0, xProgress = 0, pProgressArg = 0x0, nProgressOps = 0,
> nVTrans = 0, aModule = {htsize = 0, count = 5, first = 0x555555782100, ht
> = 0x0}, pVtabCtx = 0x0, aVTrans = 0x0, pDisconnect = 0x0,
> aFunc = {a = {0x0, 0x5555557819f0, 0x0, 0x555555781d50, 0x555555781e30,
> 0x0, 0x0, 0x555555781c90, 0x555555781f60, 0x555555781fd0, 0x0,
> 0x555555791b50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x5555557810b0}}, aCollSeq = {htsize = 0, count = 3,
> first = 0x555555780df0, ht = 0x0}, busyHandler = {xFunc = 0, pArg =
> 0x0, nBusy = 0}, aDbStatic = {{zName = 0x7ffff7bbdafe "main",
> pBt = 0x555555780e30, inTrans = 0 '\000', safety_level = 3 '\003',
> pSchema = 0x555555780f90}, {zName = 0x7ffff7bbd0ca "temp",
> pBt = 0x0, inTrans = 0 '\000', safety_level = 1 '\001', pSchema =
> 0x555555781020}}, pSavepoint = 0x0, busyTimeout = 0,
> nSavepoint = 0, nStatement = 0, nDeferredCons = 0, pnBytesFreed = 0x0,
> pBlockingConnection = 0x0, pUnlockConnection = 0x0,
> pUnlockArg = 0x0, xUnlockNotify = 0, pNextBlocked = 0x0}
>
> After four continue it aborts with the backtrace mentioned on top.
> The compilation options (CFLAGS) were:
> -O2 -fno-strict-aliasing
> -DSQLITE_SECURE_DELETE
> -DSQLITE_ENABLE_COLUMN_METADATA
> -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE=1
> -DSQLITE_SOUNDEX=1
> -DSQLITE_ENABLE_UNLOCK_NOTIFY
> -DSQLITE_OMIT_LOOKASIDE=1
> -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
>
> Removing -DSQLITE_OMIT_LOOKASIDE=1 helps a bit, the basic table creation
> works. It still doesn't pass the SQLite3 tests during compilation of
> bogofilter 1.2.2+dfsg1 . The Debian bugreport #665363 [1] states that
> 3.7.9 was working and the problem first noted in 3.7.10 .
>
> What should I do to help it being fixed? Would you need *p->db _right
> before_ the abort?
>
> Regards,
> Laszlo/GCS
> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665363
>
> _______________________________________________
> sqlite-users mailing list
> sqlite...@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>

--
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite...@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply all
Reply to author
Forward
0 new messages