From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | exclusion(at)gmail(dot)com |
Subject: | BUG #18240: Undefined behaviour in cash_mul_flt8() and friends |
Date: | 2023-12-11 06:00:02 |
Message-ID: | 18240-c5da758d7dc1ecf0@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: 18240
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 16.1
Operating system: Ubuntu 22.04
Description:
The following multiplication:
SELECT 1_000_000_000::money * 1_000_000_000::float8;
gives the incorrect result:
-$92,233,720,368,547,758.08
UBSan detects undefined behaviour:
cash.c:669:11: runtime error: 1e+20 is outside the range of representable
values of type 'long'
#0 0x55d66011b73a in cash_mul_flt8
.../src/backend/utils/adt/cash.c:669:11
The same is observed with float4:
cash.c:719:11: runtime error: 1e+20 is outside the range of representable
values of type 'long'
#0 0x55f2adc46072 in cash_mul_flt4
.../src/backend/utils/adt/cash.c:719:11
And with float8 * money...
Reproduced on REL9_6_0 (but the defect is much older, AFAICS) .. HEAD.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2023-12-11 10:22:23 | Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends |
Previous Message | Andrei Lepikhov | 2023-12-11 02:26:33 | Re: BUG #16925: ERROR: invalid DSA memory alloc request size 1073741824 CONTEXT: parallel worker |