BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: zuming(dot)jiang(at)inf(dot)ethz(dot)ch
Subject: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
Date: 2023-12-27 09:33:34
Message-ID: 18260-1b6a0c4ae311b837@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18260
Logged by: Zuming Jiang
Email address: zuming(dot)jiang(at)inf(dot)ethz(dot)ch
PostgreSQL version: 16.1
Operating system: Ubuntu 20.04
Description:

My fuzzer finds a bug in Postgres 17devel, which triggers an unexpected
error "ERROR: negative bitmapset member not allowed".

--- Set up database ---
create table t0 (vkey int4, c1 numeric);
create table t1 (vkey int4, c9 text, primary key(vkey));
create view t3 as
select
ref_3.c1 as c_0,
ref_3.c1 as c_2,
null::int4 as c_4,
right(ref_2.c9, ref_2.vkey) as c_6
from
((select ref_0.vkey as c_2 from t1 as ref_0) as subq_0
left outer join (t1 as ref_2
right outer join t0 as ref_3
on (ref_2.vkey = ref_3.vkey))
on (subq_0.c_2 = ref_3.vkey));

The fuzzer generates a test case:

--- Test case ---
with cte_1 as (select
ref_1.c_0 as c_2,
ref_1.c_4 as c_3,
case when (nullif(ref_1.c_2, ref_1.c_0) <> (
select
ref_53.c_2 as c_0
from
(t1 as ref_52 left outer join t3 as ref_53 on true)
where (ref_53.c_6) ~~ (ref_53.c_6)
order by c_0 limit 1)
) then null else null end
as c_4
from
t3 as ref_1)
select 1
from
cte_1 as ref_33
where (ref_33.c_2 > (
select
ref_200.c_2 as c_0
from
t3 as ref_200
window w0 as (partition by ref_33.c_3 order by ref_33.c_4 desc)
order by c_0 limit 1));

--- Expected behavior ---
The test case should not trigger any error.

--- Actual behavior ---
The test case trigger an error:

ERROR: negative bitmapset member not allowed

--- Postgres version ---
Github commit: 0eac3c798c2d223d6557a5440d7534317dbd4fa0
Version: PostgreSQL 17devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

--- Platform information ---
Platform: Ubuntu 20.04
Kernel: Linux 5.4.0-147-generic

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Zu-Ming Jiang 2023-12-27 10:31:21 Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
Previous Message tender wang 2023-12-27 09:22:30 Re: BUG #18259: Assertion in ExtendBufferedRelLocal() fails after no-space-left condition