Re: Remove dependence on integer wrapping

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: Remove dependence on integer wrapping
Date: 2024-07-06 23:04:38
Message-ID: CAAvxfHcDQEziyQ-ehv0Bg05OovGPGO95VoO7-DyxJx6Tkq85vA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 13, 2024 at 12:00 AM Alexander Lakhin <exclusion(at)gmail(dot)com>
wrote:
> SELECT '[]'::jsonb -> -2147483648;
>
> #4 0x00007efe232d67f3 in __GI_abort () at ./stdlib/abort.c:79
> #5 0x000055e8fde9f211 in __negvsi2 ()
> #6 0x000055e8fdcca62c in jsonb_array_element (fcinfo=0x55e8fec28220) at
jsonfuncs.c:948
>
> (gdb) f 6
> #6 0x000055e14cb9362c in jsonb_array_element (fcinfo=0x55e14d493220) at
jsonfuncs.c:948
> 948 if (-element > nelements)
> (gdb) p element
> $1 = -2147483648
>
> ---
> SELECT jsonb_delete_path('{"a":[]}', '{"a",-2147483648}');
>
> #4 0x00007f1873bef7f3 in __GI_abort () at ./stdlib/abort.c:79
> #5 0x0000564a009d2211 in __negvsi2 ()
> #6 0x0000564a00807c89 in setPathArray (it=0x7fff865c7380,
path_elems=0x564a017baf20, path_nulls=0x564a017baf40,
> path_len=2, st=0x7fff865c7388, level=1, newval=0x0, nelems=2,
op_type=2) at jsonfuncs.c:5407
>
> (gdb) f 6
> #6 0x000055985e823c89 in setPathArray (it=0x7ffc22258fe0,
path_elems=0x559860286f20, path_nulls=0x559860286f40,
> path_len=2, st=0x7ffc22258fe8, level=1, newval=0x0, nelems=0,
op_type=2) at jsonfuncs.c:5407
> 5407 if (-idx > nelems)
> (gdb) p idx
> $1 = -2147483648

I've added another patch, 0004, to resolve the jsonb wrap-arounds.

The other patches, 0001, 0002, and 0003 are unchanged but have their
version number incremented.

Thanks,
Joe Koshakow

Attachment Content-Type Size
v8-0004-Remove-dependence-on-integer-wrapping-for-jsonb.patch text/x-patch 2.4 KB
v8-0001-Remove-dependence-on-integer-wrapping.patch text/x-patch 13.5 KB
v8-0003-Remove-overflow-from-array_set_slice.patch text/x-patch 2.9 KB
v8-0002-Handle-overflow-in-money-arithmetic.patch text/x-patch 11.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul George 2024-07-07 02:45:32 Re: Eager aggregation, take 3
Previous Message Noah Misch 2024-07-06 22:46:47 Re: Vectored I/O in bulk_write.c