Re: BUG #17406: Segmentation fault on GiST index after 14.2 upgrade

From: Victor Yegorov <vyegorov(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17406: Segmentation fault on GiST index after 14.2 upgrade
Date: 2022-02-16 08:14:49
Message-ID: CAGnEbojzf-uObyWeu1MPNKaYsnL_U2kg48K6Ec43waPRBu3DrQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

вт, 15 февр. 2022 г. в 22:51, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>:

> Hmm. So I guess there are three options:
>
> 1) The index was already broken on 12.9, but for some reason (choice of
> a different plan, ...) it was not causing any issues.
>

Nope, index is actively used on 12.9, plan hasn't changed.

How large is the table/index? Are you able to run the query with a
> custom build (without values optimized out)? Any chance you still have a
> backup from before the pg_upgrade, on which you might run the query?
>

Yes, this is a test DB restored from backup in order to test out 14
upgrade, production is still running on 12.9.
v3_region is 2832 kB
region_ltree_path_idx_gist is 472 kB

For custom build I need some time to actually build it.
What options would you recommend (for configure) me to use here?

Can you print the pageItem->blkno? That should tell us which index page
> is causing issues. And then you can dump the page using pageinspect [1].
> For example if blkno = 100, then this might tell us more:
>

(gdb) frame 7
#7 gistScanPage (scan=scan(at)entry=0x55bbbd4196c8,
pageItem=pageItem(at)entry=0x7ffdac2e3fe0,
myDistances=myDistances(at)entry=0x0, tbm=tbm(at)entry=0x0, ntids=ntids(at)entry=0x0)
at ./build/../src/backend/access/gist/gistget.c:438
438 ./build/../src/backend/access/gist/gistget.c: No such file or
directory.
(gdb) p pageItem->blkno
$1 = 0
(gdb) p pageItem->data->heap
$5 = {heapPtr = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}, recheck
= false, recheckDistances = false, recontup = 0x55bbbb96927e <palloc+46>,
offnum = 38600}

This query below also crashes with SegFault:
SELECT * FROM gist_page_items(get_raw_page('region_ltree_path_idx_gist',
0), 'region_ltree_path_idx_gist');

SELECT * FROM
gist_page_items_bytea(get_raw_page('region_ltree_path_idx_gist', 0));

itemoffset | ctid | itemlen | dead |
key_data
------------+------------+---------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | (16,65535) | 72 | f |
\x00001000ffff48407b00000000ffffffffbfffffff800000000300000003003138300000000400313234300000040031323433000040000000010000000400313933300000000000
2 | (7,65535) | 72 | f |
\x00000700ffff48407b00000000fdbf7ffeffdffbff600000000200000003003231330000000400363039390000600000000200000003003233370000000400313335380000000000
3 | (13,65535) | 64 | f |
\x00000d00ffff40406b00000000fffffffffffeffff60000000020000000400313738350000040031373837000040000000010000000400313836370000000000
4 | (8,65535) | 72 | f |
\x00000800ffff48407b00000000df7fbbffffffffff600000000200000003003435360000000300343538000000600000000200000003003438300000000300363438000000000000
5 | (12,65535) | 80 | f |
\x00000c00ffff50408b00000000bffffbf5fffffffb6000000002000000020032340000000003003733310000008000000003000000030032343900000004003337373000000400333737380000000000
6 | (27,65535) | 80 | f |
\x00001b00ffff50408b00000000fbefcff3ffffefff6000000002000000030032343900000004003339323500008000000003000000030032363600000004003134343400000400313434350000000000
7 | (10,65535) | 72 | f |
\x00000a00ffff48407b00000000f7fdfffffffbffff600000000200000003003530330000000300353037000000600000000200000001003600000000000400333430330000000000
8 | (3,65535) | 64 | f |
\x00000300ffff40406b00000000f7dffffff7ffffff40000000010000000300313033000000600000000200000003003131390000000300313238000000000000
9 | (29,65535) | 80 | f |
\x00001d00ffff50408b00000000ffffffffdffff7df6000000002000000030031313900000003003133300000008000000003000000030031363400000004003130373400000400313037350000000000
10 | (30,65535) | 64 | f |
\x00001e00ffff40406b000000007dfffffffffffffb60000000020000000200313700000000030037313900000040000000010000000400313738350000000000
11 | (6,65535) | 80 | f |
\x00000600ffff50408b00000000ffbbef7ef7df7bee8000000003000000020031370000000003003731370000000300373138000000600000000200000003003137330000000400313738300000000000
12 | (32,65535) | 80 | f |
\x00002000ffff50408b000000001dfff7fbffbff7ff6000000002000000030031373300000004003137383100008000000003000000030031383000000004003132343000000400313234320000000000
13 | (17,65535) | 80 | f |
\x00001100ffff50408b00000000fdffffffffffffff6000000002000000030031333500000004003130303900008000000003000000030031363400000004003130383600000400313038370000000000
14 | (19,65535) | 72 | f |
\x00001300ffff48407b00000000fdbffefedfffff7f600000000200000002003430000000000200353100000000600000000200000003003432300000000400343737370000000000
15 | (35,65535) | 80 | f |
\x00002300ffff50408b0200000080000000030000000300343735000000040036303236000004003630323700008000000003000000020035330000000003003736330000000400323733330000000000
16 | (23,65535) | 72 | f |
\x00001700ffff48407b020000006000000002000000030033393400000004003436393300008000000003000000030034323000000003003532380000000300353239000000000000
17 | (2,65535) | 72 | f |
\x00000200ffff48407b00000000ff7eff9feffdfeff600000000200000003003236360000000400313434360000600000000200000003003238330000000400333134320000000000
18 | (37,65535) | 80 | f |
\x00002500ffff50408b00000000ffff5ffbfff7bfef6000000002000000030032383300000004003331353100008000000003000000030033323500000004003135333800000400313533390000000000
19 | (38,65535) | 88 | f |
\x00002600ffff58409b00000000ff6fffffffffffff80000000030000000300343333000000040032313134000004003231333900008000000003000000030034373500000004003539383800000400363130380000000000
20 | (34,65535) | 80 | f |
\x00002200ffff50408b00000000ffdffefffd7ffffd6000000002000000030034323000000004003438313400008000000003000000030034333300000004003231313600000400323131370000000000
21 | (39,65535) | 80 | f |
\x00002700ffff50408b00000000fdff7ff87b5e1fe58000000003000000030034333300000004003231313600000400323132300000600000000200000003003434390000000300353634000000000000
22 | (18,65535) | 80 | f |
\x00001200ffff50408b00000000ffffffffef7ffdff6000000002000000030031363400000004003130383400008000000003000000020031370000000004003237363700000400323830320000000000
23 | (40,65535) | 88 | f |
\x00002800ffff58409b00000000fffefedffd7ff2ff80000000030000000200313700000000040032373637000004003238323300008000000003000000020031370000000003003731370000000400323831310000000000
24 | (4,65535) | 64 | f |
\x00000400ffff40406b00000000febeff7dc7a367d360000000020000000300343439000000030035363800000040000000010000000300343630000000000000
25 | (41,65535) | 72 | f |
\x00002900ffff48407b00000000dfffbfbd7effedff600000000200000003003436300000000300343632000000600000000200000003003437350000000400363130360000000000
26 | (22,65535) | 80 | f |
\x00001600ffff50408b00000000d9ffc3ffffffbff68000000003000000030034373500000004003631303600000400363130370000600000000200000003003438360000000300343931000000000000
27 | (42,65535) | 72 | f |
\x00002a00ffff48407b00000000bf7fbfdaf9f9ffff600000000200000003003438360000000400353032320000600000000200000003003530330000000300353034000000000000
28 | (1,65535) | 80 | f |
\x00000100ffff50408b00000000efdfffffffbffffe6000000002000000030031303300000004003139353500008000000003000000030031313300000003003931310000000300393132000000000000
29 | (43,65535) | 80 | f |
\x00002b00ffff50408b00000000ffffefdfffffffff6000000002000000030031313300000003003931370000008000000003000000030031333500000004003130303600000400313030380000000000
30 | (28,65535) | 72 | f |
\x00001c00ffff48407b00000000effffeffeffffef7600000000200000001003600000000000400333531370000600000000200000002003730000000000200373100000000000000
31 | (44,65535) | 72 | f |
\x00002c00ffff48407b00000000f3bfff6fff7fbffc600000000200000002003730000000000200373300000000600000000200000002003837000000000200393100000000000000
32 | (45,65535) | 80 | f |
\x00002d00ffff50408b0200000080000000030000000300333039000000040033353437000004003335343800008000000003000000030034333300000004003231313400000400323133320000000000
33 | (36,65535) | 80 | f |
\x00002400ffff50408b00000000feeeffdff876fff36000000002000000030034323000000003003533300000008000000003000000030034333300000004003232313300000400323231370000000000
34 | (46,65535) | 80 | f |
\x00002e00ffff50408b00000000fec7df33bff7ff6f8000000003000000030034333300000004003232313300000400323233360000600000000200000003003435330000000300353834000000000000
35 | (5,65535) | 88 | f |
\x00000500ffff58409b00000000fffef9dd67feefff80000000030000000300323636000000040031343436000004003134343700008000000003000000030032383300000004003330303300000400333030340000000000
36 | (47,65535) | 72 | f |
\x00002f00ffff48407b000000007eefbfffbfffffff600000000200000003003238330000000400333030350000600000000200000003003330390000000300333133000000000000
37 | (20,65535) | 80 | f |
\x00001400ffff50408b00000000fbaf67cafdff7aff6000000002000000020037380000000002003739000000008000000003000000020039320000000004003430303100000400343030320000000000
38 | (48,65535) | 80 | f |
\x00003000ffff50408b00000000ffbffffedbcfeff38000000003000000020039320000000004003430303100000400343030370000600000000200000002003937000000000200393900000000000000
39 | (9,65535) | 80 | f |
\x00000900ffff50408b00000000fff5fffd5dfbf3ef6000000002000000030033373100000003003337370000008000000003000000030033383900000004003136383700000400313638380000000000
40 | (49,65535) | 80 | f |
\x00003100ffff50408b00000000eff7ff7ff9edffab8000000003000000030033383900000004003139373400000400313937350000600000000200000002003430000000000200343800000000000000
41 | (25,65535) | 72 | f |
\x00001900ffff48407b00000000bfffffffef7f9fff800000000300000002003137000000000300373137000000040032383337000040000000010000000400313839330000000000
42 | (50,65535) | 64 | f |
\x00003200ffff40406b00000000bfeffe75dbebf7fb40000000010000000400313839340000600000000200000003003231330000000400363038340000000000
43 | (14,65535) | 80 | f |
\x00000e00ffff50408b00000000ffffffffffbfffff8000000003000000030032313300000004003630383400000400363038350000600000000200000003003234390000000400333838380000000000
44 | (51,65535) | 88 | f |
\x00003300ffff58409b00000000fffffff6fff6dfbf80000000030000000300323439000000040033383838000004003338383900008000000003000000030033303900000004003334323000000400333531390000000000
45 | (15,65535) | 72 | f |
\x00000f00ffff48407b00000000cfefe3ff3efdfd6f600000000200000003003332350000000400313534300000600000000200000003003336300000000400313538370000000000
46 | (52,65535) | 80 | f |
\x00003400ffff50408b00000000ffaeffb88affafdd8000000003000000030033363000000004003135383700000400313538380000600000000200000003003337310000000300333732000000000000
47 | (24,65535) | 80 | f |
\x00001800ffff50408b00000000af3ffffd7f7ff5ed6000000002000000030033303900000003003331350000008000000003000000030033323700000004003532363800000400353236390000000000
48 | (53,65535) | 80 | f |
\x00003500ffff50408b00000000ff3ffbfaf8fded7d8000000003000000030033323700000004003532393200000400353239330000600000000200000003003337310000000400313631390000000000
49 | (11,65535) | 80 | f |
\x00000b00ffff50408b00000000fff5ffffeefbf2af8000000003000000030033373100000004003136323900000400313633300000600000000200000003003338360000000400353134310000000000
50 | (54,65535) | 72 | f |
\x00003600ffff48407b00000000ffefbffbef7bf3df600000000200000003003338360000000400353138360000600000000200000003003339340000000400343433380000000000
51 | (21,65535) | 88 | f |
\x00001500ffff58409b00000000cefbbbbbb6fe9ebf80000000030000000300323337000000040031333538000004003133353900008000000003000000030032333900000004003437333300000400343733340000000000
52 | (55,65535) | 80 | f |
\x00003700ffff50408b00000000fbe1df8fef3fff7d6000000002000000030032333900000004003438333500008000000003000000020032340000000003003732390000000300373330000000000000
53 | (33,65535) | 80 | f |
\x00002100ffff50408b000000008ffbb9fffffbf7676000000002000000030031363400000004003130383800008000000003000000030031363800000004003437323000000400343732310000000000
54 | (56,65535) | 88 | f |
\x00003800ffff58409b00000000ffdfff7ffeabfffa80000000030000000300313638000000040034373230000004003437343900008000000003000000020031370000000003003639340000000300363935000000000000
55 | (31,65535) | 88 | f |
\x00001f00ffff58409b00000000df8dfddefffefbd580000000030000000200353300000000030037363300000004003237353500008000000003000000010036000000000003003638360000000300363837000000000000
56 | (57,65535) | 88 | f |
\x00003900ffff58409b00000000ef3afffdf4f5f7ff80000000030000000100360000000000030036383800000003003638390000008000000003000000020037380000000003003738340000000300373835000000000000
57 | (26,65535) | 80 | f |
\x00001a00ffff50408b00000000f37fafbdb1f7afbd6000000002000000030034383000000003003635300000008000000003000000030034393800000004003232303100000400323231310000000000
58 | (58,65535) | 88 | f |
\x00003a00ffff58409b00000000fffeff9d6f71dbef80000000030000000300343938000000040032323332000004003232333500008000000003000000030035323000000004003630373500000400363130350000000000
(58 rows)

--
Victor Yegorov

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-02-16 10:13:19 BUG #17407: trim trims more than expected
Previous Message wliang 2022-02-16 08:13:26 Re: Report a potential memory leak in setup_config()