On Thu, Jun 13, 2024 at 12:00 AM Alexander Lakhin <
exclusion@gmail.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