On Mon Oct 31, 2016 at 05:42:32PM -0400, Richard Hipp wrote:
> On 10/31/16, mark <no...@null.net> wrote:
> > On Mon Oct 31, 2016 at 04:04:00PM -0400, Richard Hipp wrote:
> >> Is this reproducible?
> >
> > Yes... in that I can reliably get it to segfault. Duplicating the build
> > and/or statements leading up to the fault outside of my environment
> > is not so easy. Unless I make the virtual machine image available to
> > you somehow...
> 
> I cannot reproduce the problem on Linux.  Even running under valgrind
> shows no issues.

I can no longer reproduce the original segmentation fault. I still have
errors (back to aborting again) so I'll just follow this through
wherever it leads to.

> Can you please recompile using -DSQLITE_DEBUG and try again.

For completeness here are the rest of the options I'm using:

        -DSQLITE_DEBUG
        -DSQLITE_ENABLE_COLUMN_METADATA
        -DSQLITE_ENABLE_FTS3_PARENTHESIS
        -DSQLITE_ENABLE_FTS4
        -DSQLITE_ENABLE_FTS5
        -DSQLITE_ENABLE_JSON1
        -DSQLITE_ENABLE_RTREE
        -DSQLITE_ENABLE_STAT3
        -DSQLITE_ENABLE_STAT4
        -DSQLITE_OMIT_LOAD_EXTENSION

I see one warning during compilation:

        sqlite3.c: In function 'sqlite3VdbeExec':
        sqlite3.c:78265: warning: comparison is always true due to limited 
range of data type

The sqlite3.c source file should be the one that is here:

        https://api.metacpan.org/source/ISHIGAKI/DBD-SQLite-1.51_06/sqlite3.c

> If that works, please insert an extra SQL statement just before the
> SQL statement that is causing the problem, that says:
> 
>      PRAGMA debug=ON;

Even with -DSQLITE_DEBUG the "debug" pragma doesn't seem to do anything
for me (and I can't find it in the documentation). Using "vdbe_debug"
(perhaps what you meant?) I now see the following:

    SQL: [PRAGMA
        vdbe_debug=on
    ;]
    VDBE Program Listing:
       0 Init             0    1    0               00 Start at 1
       1 Expire           0    0    0               00 
       2 Halt             0    0    0               00 
    VDBE Trace:
       0 Init             0    1    0               00 Start at 1
    SQL-trace: PRAGMA
        vdbe_debug=on
    ;
       1 Expire           0    0    0               00 
       2 Halt             0    0    0               00 
    assertion "0" failed: file "sqlite3.c", line 70020, function "valueFromExpr"
    Abort trap (core dumped)

I'm not sure about the line numbers. 70020 in my source (looking at the
file with vim) is not an assert. The backtrace looks like this:

    #0  0x000017dc6b94f68a in thrkill () at <stdin>:2
    #1  0x000017dc6b9223e9 in *_libc_abort ()
        at /usr/src/lib/libc/stdlib/abort.c:52
    #2  0x000017dc6b924e84 in *_libc___assert2 (file=)
        at /usr/src/lib/libc/gen/assert.c:52
    #3  0x000017d9707fb288 in valueFromExpr (db=0x17dbbac8e808, 
        pExpr=0x17dc0252b288, enc=1 '\001', affinity=68 'D', 
ppVal=0x7f7ffffe7f08, 
        pCtx=0x7f7ffffe7f70) at sqlite3.c:70020
    #4  0x000017d9707fbaa0 in stat4ValueFromExpr (pParse=0x17db76d8fc08, pExpr=)
        at sqlite3.c:70249
    #5  0x000017d9707fbbdb in sqlite3Stat4ProbeSetValue (pParse=0x17db76d8fc08, 
        pIdx=0x17dbe04aab08, ppRec=) at sqlite3.c:70316
    #6  0x000017d97080b136 in whereEqualScanEst (pParse=0x17db76d8fc08, 
        pBuilder=0x7f7ffffe8700, pExpr=) at sqlite3.c:129373
    #7  0x000017d97080e776 in whereLoopAddBtreeIndex (pBuilder=0x7f7ffffe8700, 
        pSrc=0x17dc0252b310, pProbe=0x17dbe04aab08, nInMul=0) at 
sqlite3.c:130285
    #8  0x000017d97080f327 in whereLoopAddBtree (pBuilder=0x7f7ffffe8700, 
        mPrereq=0) at sqlite3.c:130713
    #9  0x000017d970810357 in sqlite3WhereBegin (pParse=0x17db76d8fc08, 
        pTabList=0x17dc0252b308, pWhere=) at sqlite3.c:131185
    #10 0x000017d9708203c6 in fkScanChildren (pParse=0x17db76d8fc08, 
        pSrc=0x17dc0252b308, pTab=0x17dc3f7f6a08, pIdx=0x0, 
pFKey=0x17dbd9f4ae88, 
        aiCol=0x0, regData=11, nIncr=-1) at sqlite3.c:106565
    #11 0x000017d970837f22 in sqlite3FkCheck (pParse=0x17db76d8fc08, 
        pTab=0x17dc3f7f6a08, regOld=0, regNew=11, aChange=0x0, bChngRowid=0)
        at sqlite3.c:106943
    #12 0x000017d97083ad6d in sqlite3Insert (pParse=0x17db76d8fc08, 
        pTabList=0x17dc0252d688, pSelect=0x17dc02533f88, 
pColumn=0x17dc02534888, 
        onError=) at sqlite3.c:108341
    #13 0x000017d97083b670 in getRowTrigger (pParse=0x7f7ffffe9200, 
        pTrigger=0x17dbfda80208, pTab=) at sqlite3.c:120948
    #14 0x000017d97083babc in sqlite3CodeRowTriggerDirect 
(pParse=0x7f7ffffe9200, 
        p=0x17dbfda80208, pTab=0x17dba8948208, reg=-10, orconf=10, 
ignoreJump=-1)
        at sqlite3.c:121176
    #15 0x000017d97083bd44 in sqlite3CodeRowTrigger (pParse=0x7f7ffffe9200, 
        pTrigger=0x6, op=108, pChanges=0x0, tr_tm=2, pTab=0x17dba8948208, 
reg=-10, 
        orconf=10, ignoreJump=-1) at sqlite3.c:121270
    #16 0x000017d97083ae32 in sqlite3Insert (pParse=0x7f7ffffe9200, 
        pTabList=0x17dc02533388, pSelect=0x0, pColumn=0x17dc02532788, 
onError=512)
        at sqlite3.c:108355
    #17 0x000017d9708239be in sqlite3Parser (yyp=0x17dbd5c29368, yymajor=)
        at sqlite3.c:135614
    #18 0x000017d970826118 in sqlite3RunParser (pParse=0x7f7ffffe9200, 
        zSql=0x17db9b16a600 "INSERT INTO\n    func_begin_change(\n        
author,\n        author_contact,\n        author_contact_method,\n        
author_shortname,\n        id,\n        lang,\n        mtime,\n        
mtimetz,\n        pa"..., pzErrMsg=0x7f7ffffe9468) at sqlite3.c:137350
    #19 0x000017d970826e02 in sqlite3Prepare (db=0x17dbbac8e808, 
        zSql=0x17db9b16a600 "INSERT INTO\n    func_begin_change(\n        
author,\n        author_contact,\n        author_contact_method,\n        
author_shortname,\n        id,\n        lang,\n        mtime,\n        
mtimetz,\n        pa"..., nBytes=0, saveSqlFlag=1, pReprepare=) at 
sqlite3.c:114088
    #20 0x000017d9708271b8 in sqlite3LockAndPrepare (db=0x17dbbac8e808, 
        zSql=0x17db9b16a600 "INSERT INTO\n    func_begin_change(\n        
author,\n        author_contact,\n        author_contact_method,\n        
author_shortname,\n        id,\n        lang,\n        mtime,\n        
mtimetz,\n        pa"..., nBytes=-1, saveSqlFlag=1, pOld=0x0, 
ppStmt=0x17dbde174ac0, 
        pzTail=0x7f7ffffe9558) at sqlite3.c:114179
    #21 0x000017d970827426 in sqlite3_prepare_v2 (db=) at sqlite3.c:114255
    #22 0x000017d9707a14a2 in sqlite_st_prepare_sv (sth=0x17dbdb019280, 
        imp_sth=0x17dbde174a00, sv_statement=) at dbdimp.c:862
    #23 0x000017d970797cb6 in XS_DBD__SQLite__st__prepare (cv=) at 
SQLite.xsi:478
    #24 0x000017d970915127 in Perl_pp_entersub () at pp_hot.c:2794
    #25 0x000017d97090e181 in Perl_runops_standard () at run.c:42
    #26 0x000017d9708b05bf in Perl_call_sv (sv=0x17dbdb0191a8, flags=2)
        at perl.c:2760
    #27 0x000017d970890522 in XS_DBI_dispatch (cv=0x17db7413b018) at DBI.xs:3800
    #28 0x000017d970915127 in Perl_pp_entersub () at pp_hot.c:2794
    #29 0x000017d97090e181 in Perl_runops_standard () at run.c:42
    #30 0x000017d9708b0f96 in perl_run (my_perl=) at perl.c:2460
    #31 0x000017d970744e3d in main (argc=5, argv=0x7f7ffffe9c98) at 
bundle.c:16074

Various other things that may help:

        (gdb) select-frame 3
        (gdb) print *db
        $1 = {pVfs = 0x17d970f72b80, pVdbe = 0x17dc2edc6008,
          pDfltColl = 0x17dc17b44d08, mutex = 0x0, aDb = 0x17dbbac8ea38, nDb = 
2,
          flags = 18744929, lastRowid = 0, szMmap = 0, openFlags = 6, errCode = 
0,
          errMask = 255, iSysErrno = 0, dbOptFlags = 0, enc = 1 '\001',
          autoCommit = 0 '\0', temp_store = 2 '\002', mallocFailed = 0 '\0',
          bBenignMalloc = 0 '\0', dfltLockMode = 0 '\0', nextAutovac = -1 '???',
          suppressErr = 0 '\0', vtabOnConflict = 0 '\0',
          isTransactionSavepoint = 0 '\0', mTrace = 0 '\0', nextPagesize = 0,
          magic = 2687084183, nChange = 1, nTotalChange = 1, aLimit = 
{1000000000,
                1000000000, 2000, 1000, 500, 25000, 127, 10, 50000, 999, 1000, 
0},
          nMaxSorterMmap = 2147483647, init = {newTnum = 1, iDb = 0 '\0',
                busy = 0 '\0', orphanTrigger = 0 '\0', imposterTable = 0 '\0'},
          nVdbeActive = 0, nVdbeRead = 0, nVdbeWrite = 0, nVdbeExec = 0,
          nVDestroy = 0, 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 = 0x17d9707f66fd <sqlite3WalDefaultHook>, pWalArg = 
0x3e8,
          xCollNeeded = 0x17d97079bd1e <sqlite_db_collation_needed_dispatcher>,
          xCollNeeded16 = 0, pCollNeededArg = 0x17dc62cb7cd8, pErr = 0x0, u1 = {
                isInterrupted = 0, notUsed1 = 0}, lookaside = {bDisable = 0, sz 
= 128,
                bMalloced = 1 '\001', nOut = 370, mxOut = 370, anStat = {938, 
146, 0},
                pFree = 0x17dc0252b088, pStart = 0x17dc02527008, pEnd = 
0x17dc02536a08},
        ---Type <return> to continue, or q <return> to quit---
          xAuth = 0, pAuthArg = 0x0, xProgress = 0, pProgressArg = 0x0,
          nProgressOps = 0, nVTrans = 0, aModule = {htsize = 20, count = 10,
                first = 0x17dbfda818c8, ht = 0x17dc65266c08}, pVtabCtx = 0x0,
          aVTrans = 0x0, pDisconnect = 0x0, aFunc = {htsize = 64, count = 44,
                first = 0x17dbeade36c8, ht = 0x17dc32e0c808}, aCollSeq = 
{htsize = 0,
                count = 3, first = 0x17dc112ceac8, ht = 0x0}, busyHandler = {
                xFunc = 0x17d9707ac9a5 <sqliteDefaultBusyCallback>, pArg = 
0x17dbbac8e808,
                nBusy = 0}, aDbStatic = {{zDbSName = 0x17d970bc4fff "main",
                  pBt = 0x17dba8948d08, safety_level = 2 '\002', bSyncSet = 1 
'\001',
                  pSchema = 0x17dc43f9a008}, {zDbSName = 0x17d970bd6b0c "temp", 
pBt = 0x0,
                  safety_level = 1 '\001', bSyncSet = 0 '\0', pSchema = 
0x17dbfda80008}},
          pSavepoint = 0x0, busyTimeout = 30000, nSavepoint = 0, nStatement = 0,
          nDeferredCons = 0, nDeferredImmCons = 0, pnBytesFreed = 0x0}
        (gdb)
        (gdb) print *pCtx
        $2 = {pParse = 0x17db76d8fc08, pIdx = 0x17dbe04aab08, ppRec = 
0x7f7ffffe7ff0,
          iVal = 0}
        (gdb) info locals
        op = 157
        zVal = Variable "zVal" is not available.
        (gdb) print *pExpr
        $3 = {op = 157 '\235', affinity = 68 'D', flags = 4, u = {
                zToken = 0x17dc0252b2d0 "", iValue = 38974160}, pLeft = 0x0, 
pRight = 0x0,
          x = {pList = 0x0, pSelect = 0x0}, nHeight = 1, iTable = 11, iColumn = 
0,
          iAgg = -1, iRightJoinTable = 0, op2 = 0 '\0', pAggInfo = 0x0, pTab = 
0x0}
        (gdb) print *ppVal
        $4 = (sqlite3_value *) 0x0

Regards,
Mark
-- 
Mark Lawrence
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to