Re: BUG #17781: Assert in setrefs.c - Mailing list pgsql-bugs

From Robins Tharakan
Subject Re: BUG #17781: Assert in setrefs.c
Date
Msg-id CAEP4nAzgCUWd1RWq81Twpud2yAkZejMRqfSoKbvMsdEqHq4KBg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17781: Assert in setrefs.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #17781: Assert in setrefs.c
Re: BUG #17781: Assert in setrefs.c
List pgsql-bugs
Hi Tom,

Assuming this persistence is helpful overall, now I see a
different SQL can still trigger the same assert().

On Wed, 8 Feb 2023 at 09:56, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > This assert() is easily reproducible as of aa69541046@master, although I can
> > trace the issue back to last week's commit 2489d76c49.
>
> Pushed a fix, thanks!


TRAP: failed Assert("nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match
== NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels,
phv->phnullingrels) : bms_equal(subphv->phnullingrels,
phv->phnullingrels)"), File: "setrefs.c", Line: 2845, PID: 803757


SQL
===
rollback;
begin;
create table t();
SELECT ref_1.definition AS c4
FROM t AS sample_1
     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON NULL
WHERE pg_catalog."user"() IS NOT NULL;


Checking (fee7b77b90~0) - fee7b77b90 - Crash
Checking (fee7b77b90~1) - e2c78e7ab4 - Success
Checking (fee7b77b90~2) - 2cbbffff05 - Success


=== Backtrace - PID 803757 - fee7b77b90@master ===
Core was generated by `postgres: fee7b77b90@master@sqith: ubuntu t
127.0.0.1(60194) SELECT           '.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f76d487e859 in __GI_abort () at abort.c:79
#2  0x000055c7f48e9126 in ExceptionalCondition (
    conditionName=0x55c7f4aa0ec0 "nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match
== NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels,
phv->phnullingrels) : bms_equal(subphv->phnullingr"...,
fileName=0x55c7f4aa08ef "setrefs.c", lineNumber=2845) at assert.c:66
#3  0x000055c7f45d8df7 in search_indexed_tlist_for_phv (phv=0x55c7f6bd3b68,
    itlist=0x55c7f6bdf988, newvarno=-2, nrm_match=NRM_EQUAL) at setrefs.c:2845
#4  0x000055c7f45d959c in fix_upper_expr_mutator (node=0x55c7f6bd3b68,
    context=0x7ffec773f9e0) at setrefs.c:3188
#5  0x000055c7f45d9482 in fix_upper_expr (root=0x55c7f6bcca28,
    node=0x55c7f6bd3b68, subplan_itlist=0x55c7f6bdf988, newvarno=-2,
    rtoffset=0, nrm_match=NRM_EQUAL, num_exec=2910) at setrefs.c:3158
#6  0x000055c7f45d8271 in set_upper_references (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8, rtoffset=0) at setrefs.c:2423
#7  0x000055c7f45d5406 in set_plan_refs (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8, rtoffset=0) at setrefs.c:1034
#8  0x000055c7f45d39ee in set_plan_references (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8) at setrefs.c:354
#9  0x000055c7f45c539c in standard_planner (parse=0x55c7f6a5f7f8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0) at planner.c:504
#10 0x00007f76d186c08b in pgss_planner (parse=0x55c7f6a5f7f8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0)
    at pg_stat_statements.c:954
#11 0x000055c7f45c4c3d in planner (parse=0x55c7f6a5f7f8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0) at planner.c:279
#12 0x000055c7f4709d72 in pg_plan_query (querytree=0x55c7f6a5f7f8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0) at postgres.c:870
#13 0x000055c7f4709eca in pg_plan_queries (querytrees=0x55c7f6bb4eb8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0) at postgres.c:962
#14 0x000055c7f470a2ad in exec_simple_query (
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;") at postgres.c:1156
#15 0x000055c7f470f163 in PostgresMain (dbname=0x55c7f6a59478 "t",
    username=0x55c7f6a9f5f8 "ubuntu") at postgres.c:4565
#16 0x000055c7f4637d4d in BackendRun (port=0x55c7f6a953d0)
    at postmaster.c:4461
#17 0x000055c7f4637620 in BackendStartup (port=0x55c7f6a953d0)
    at postmaster.c:4189
#18 0x000055c7f4633a4f in ServerLoop () at postmaster.c:1779
#19 0x000055c7f4633324 in PostmasterMain (argc=3, argv=0x55c7f6a573d0)
    at postmaster.c:1463
#20 0x000055c7f44e65eb in main (argc=3, argv=0x55c7f6a573d0) at main.c:200

=== Backtrace FULL - PID 803757 - fee7b77b90@master ===
#2  0x000055c7f48e9126 in ExceptionalCondition (
    conditionName=0x55c7f4aa0ec0 "nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match
== NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels,
phv->phnullingrels) : bms_equal(subphv->phnullingr"...,
fileName=0x55c7f4aa08ef "setrefs.c", lineNumber=2845) at assert.c:66
No locals.
#3  0x000055c7f45d8df7 in search_indexed_tlist_for_phv (phv=0x55c7f6bd3b68,
    itlist=0x55c7f6bdf988, newvarno=-2, nrm_match=NRM_EQUAL) at setrefs.c:2845
        subphv = 0x55c7f6bdeaa8
        newvar = 0x16e455bdfc6eef00
        tle = 0x55c7f6bdf1b8
        lc__state = {l = 0x55c7f6bdf208, i = 0}
        lc = 0x55c7f6bdf220
#4  0x000055c7f45d959c in fix_upper_expr_mutator (node=0x55c7f6bd3b68,
    context=0x7ffec773f9e0) at setrefs.c:3188
        phv = 0x55c7f6bd3b68
        newvar = 0x55c7f6a5e3f0
        __func__ = "fix_upper_expr_mutator"
#5  0x000055c7f45d9482 in fix_upper_expr (root=0x55c7f6bcca28,
    node=0x55c7f6bd3b68, subplan_itlist=0x55c7f6bdf988, newvarno=-2,
    rtoffset=0, nrm_match=NRM_EQUAL, num_exec=2910) at setrefs.c:3158
        context = {root = 0x55c7f6bcca28, subplan_itlist = 0x55c7f6bdf988,
          newvarno = -2, rtoffset = 0, nrm_match = NRM_EQUAL, num_exec = 2910}
#6  0x000055c7f45d8271 in set_upper_references (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8, rtoffset=0) at setrefs.c:2423
        tle = 0x55c7f6bdf778
        newexpr = 0x8
        l__state = {l = 0x55c7f6bdf7c8, i = 0}
        subplan = 0x55c7f6bdf508
        subplan_itlist = 0x55c7f6bdf988
        output_targetlist = 0x0
        l = 0x55c7f6bdf7e0
#7  0x000055c7f45d5406 in set_plan_refs (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8, rtoffset=0) at setrefs.c:1034
        splan = 0x55c7f6bdf6e8
        l = 0x55c7f6a5e3f0
        __func__ = "set_plan_refs"
#8  0x000055c7f45d39ee in set_plan_references (root=0x55c7f6bcca28,
    plan=0x55c7f6bdf6e8) at setrefs.c:354
        result = 0x55c7f6bd3b18
        glob = 0x55c7f6bcbea8
        rtoffset = 0
        lc = 0x0
#9  0x000055c7f45c539c in standard_planner (parse=0x55c7f6a5f7f8,
    query_string=0x55c7f6a5e508 "SELECT ref_1.definition AS c4\nFROM t
AS sample_1\n     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON
NULL\nWHERE pg_catalog.\"user\"() IS NOT NULL;", cursorOptions=2048,
boundParams=0x0) at planner.c:504
        result = 0x0
        glob = 0x55c7f6bcbea8
        tuple_fraction = 0
        root = 0x55c7f6bcca28
        final_rel = 0x55c7f6bdd948
        best_path = 0x55c7f6bdef38
        top_plan = 0x55c7f6bdf6e8
        lp = 0x4d430000
        lr = 0x55c7f6bb4eb8



2023-02-08 01:35:21.274 UTC [4051201] LOG:  server process (PID
803757) was terminated by signal 6: Aborted
2023-02-08 01:35:21.274 UTC [4051201] DETAIL:  Failed process was
running: SELECT ref_1.definition AS c4
FROM t AS sample_1
     LEFT JOIN pg_catalog.pg_rules AS ref_1 ON NULL
WHERE pg_catalog."user"() IS NOT NULL;
2023-02-08 01:35:21.274 UTC [4051201] LOG:  terminating any other
active server processes

As earlier, thanks to SQLSmith / SQLReduce.

-
Robins Tharakan
Amazon Web Services



pgsql-bugs by date:

Previous
From:
Date:
Subject: Re: Was there a bug fix in the COPY command in Version 15?
Next
From: Richard Guo
Date:
Subject: Re: BUG #17781: Assert in setrefs.c