Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
701 stars 145 forks source link

Segmentation fault. at src/multicorn.c:688 #146

Open raarts opened 8 years ago

raarts commented 8 years ago

I found this coredump while using https://github.com/rotten/rethinkdb-multicorn-postgresql-fdw. Is it possible for a python plugin to crash multicorn? I tested this in PG9.6beta, but it also happened on 9.3. What's the next step?

Here's the backtrace:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:30
30  ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory.
(gdb) bt full
#0  __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:30
No locals.
#1  0x00007f5d28fb54c6 in multicornBeginForeignModify (mtstate=<optimized out>, resultRelInfo=0x266fae0, fdw_private=<optimized out>, subplan_index=<optimized out>,
    eflags=<optimized out>) at src/multicorn.c:688
        att = <optimized out>
        modstate = 0x26707a8
        rel = <optimized out>
        desc = <optimized out>
        ps = <optimized out>
        subplan = 0x2586400
        i = <optimized out>
#2  0x00000000005cbe5d in ExecInitModifyTable (node=0x25864e0, estate=0x266f9a0, eflags=0) at nodeModifyTable.c:1630
        fdw_private = <optimized out>
        mtstate = 0x266fe00
        operation = CMD_INSERT
        saved_resultRelInfo = 0x0
        resultRelInfo = 0x266fae0
        tupDesc = <optimized out>
        subplan = 0x2586400
        l = 0x2586490
        i = 0
        __func__ = "ExecInitModifyTable"
#3  0x00000000005b2753 in ExecInitNode (node=node@entry=0x25864e0, estate=estate@entry=0x266f9a0, eflags=eflags@entry=0) at execProcnode.c:159
        result = <optimized out>
        subps = <optimized out>
        l = <optimized out>
        __func__ = "ExecInitNode"
#4  0x00000000005b002c in InitPlan (eflags=0, queryDesc=<optimized out>) at execMain.c:959
        plan = 0x25864e0
        tupType = <optimized out>
        operation = CMD_INSERT
        plannedstmt = <optimized out>
        rangeTable = <optimized out>
        estate = 0x266f9a0
        planstate = <optimized out>
        l = <optimized out>
        i = <optimized out>
#5  standard_ExecutorStart (queryDesc=<optimized out>, eflags=0) at execMain.c:238
        estate = <optimized out>
        __func__ = "standard_ExecutorStart"
#6  0x00000000006b45ca in ProcessQuery (plan=<optimized out>,
    sourceText=0x25dce70 "insert into users (id, somekey, someotherkey) values ('68d04b40-3847-4508-86cd-fa7dd15a2cbd', 'Hallo', 'Ron');", params=0x0, dest=0x2586750,
    completionTag=0x7ffc27009e90 "") at pquery.c:180
        queryDesc = 0x26bc5b0
---Type <return> to continue, or q <return> to quit---
        __func__ = "ProcessQuery"
#7  0x00000000006b47fc in PortalRunMulti (portal=portal@entry=0x2642a80, isTopLevel=isTopLevel@entry=1 '\001', dest=dest@entry=0x2586750, altdest=altdest@entry=0x2586750,
    completionTag=completionTag@entry=0x7ffc27009e90 "") at pquery.c:1267
        pstmt = 0x25867e0
        stmt = 0x25867e0
        active_snapshot_set = 1 '\001'
        stmtlist_item = 0x2586c80
#8  0x00000000006b5239 in PortalRun (portal=0x2642a80, count=9223372036854775807, isTopLevel=<optimized out>, dest=0x2586750, altdest=0x2586750,
    completionTag=0x7ffc27009e90 "") at pquery.c:813
        save_exception_stack = 0x7ffc27009f10
        save_context_stack = 0x0
        local_sigjmp_buf = {{__jmpbuf = {39706128, -3257218035020444439, 39706208, 39348048, 39218784, 2, 3257302909544320233, -3257213679080157975}, __mask_was_saved = 0,
            __saved_mask = {__val = {0, 1, 39603056, 9607550, 40118912, 9607550, 1, 1, 88, 40118912, 39706208, 9490698, 8118641, 9490698, 2, 40118912}}}}
        result = <optimized out>
        nprocessed = <optimized out>
        saveTopTransactionResourceOwner = 0x2568048
        saveTopTransactionContext = 0x2566e60
        saveActivePortal = 0x0
        saveResourceOwner = 0x2568048
        savePortalContext = 0x0
        saveMemoryContext = 0x2566e60
        __func__ = "PortalRun"
#9  0x00000000006b2ebb in exec_simple_query (query_string=<optimized out>) at postgres.c:1094
        portal = 0x2642a80
        snapshot_set = -128 '\200'
        commandTag = 0x2586750 "\020^G"
        completionTag = "\000ELECT 0\000\264y2]\177\000\000\000\000\000\000\000\000\000\000*\346C\000\000\000\000\000\070\372?2]\177\000\000\340d\f3]\177\000\000\000\000\000\000\000\000\000\000~6}\000\000\000\000"
        querytree_list = 0x74
        receiver = 0x2586750
        format = 0
        dest = DestRemote
        msec_str = '\000' <repeats 31 times>
        parsetree_item = 0x25dde60
#10 PostgresMain (argc=40118912, argv=0x25dde10, dbname=0x2567490 "test", username=0x25dde60 "\020\336]\002") at postgres.c:4059
        firstchar = 39706128
        input_message = {data = 0x25dce70 "insert into users (id, somekey, someotherkey) values ('68d04b40-3847-4508-86cd-fa7dd15a2cbd', 'Hallo', 'Ron');", len = 111,
          maxlen = 1024, cursor = 111}
        local_sigjmp_buf = {{__jmpbuf = {39220696, -3257213328457577239, 39220336, 0, 0, 39371744, 3257302909772909801, -3257213681102730007}, __mask_was_saved = 1,
            __saved_mask = {__val = {0, 39220368, 140720962839904, 39348512, 1024, 140720962838576, 39220696, 0, 8118429, 69, 140720962838480, 140720962838576, 6145790,
                12580992, 8040908, 39349040}}}}
        send_ready_for_query = 0 '\000'
        __func__ = "PostgresMain"
#11 0x000000000046c148 in BackendRun (port=0x258c220) at postmaster.c:4258
---Type <return> to continue, or q <return> to quit---
        ac = 1
        secs = 517519145
        usecs = 930746
        i = 1
        av = 0x25675d8
        maxac = <optimized out>
#12 BackendStartup (port=0x258c220) at postmaster.c:3932
        bn = 0x258c3e0
        pid = 0
#13 ServerLoop () at postmaster.c:1690
        rmask = {fds_bits = {32, 0 <repeats 15 times>}}
        selres = <optimized out>
        now = <optimized out>
        readmask = {fds_bits = {56, 0 <repeats 15 times>}}
        last_lockfile_recheck_time = <optimized out>
        last_touch_time = <optimized out>
        __func__ = "ServerLoop"
#14 0x0000000000659dae in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x2566250) at postmaster.c:1298
        opt = <optimized out>
        status = <optimized out>
        userDoption = <optimized out>
        listen_addr_saved = <optimized out>
        i = <optimized out>
        output_config_variable = <optimized out>
        __func__ = "PostmasterMain"
#15 0x000000000046d14d in main (argc=3, argv=0x2566250) at main.c:228

For future reference, the line causing the coredump is:

        for (i = 0; i < desc->natts; i++)
        {
                Form_pg_attribute att = desc->attrs[i];

                if (!att->attisdropped)
                {
                        if (strcmp(NameStr(att->attname), modstate->rowidAttrName) == 0)
====> modstate->rowidAttrName == NULL here
                        {
                                modstate->rowidCinfo = modstate->cinfos[i];
                                break;
                        }
                }
        }
        modstate->rowidAttno = ExecFindJunkAttributeInTlist(subplan->targetlist, modstate->rowidAttrName);
        resultRelInfo->ri_FdwState = modstate;