Re: BUG #16369: Segmentation Faults and Data Corruption with Generated Columns
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Michael Paquier <michael@paquier.xyz>, Tom Lane <tgl@sss.pgh.pa.us>, cameron.ezell@clearcapital.com, pgsql-bugs@lists.postgresql.org
Date: 2020-04-17T10:01:26Z
Lists: pgsql-bugs
On Fri, 17 Apr 2020 at 21:04, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
>
> I've tried creating a smaller test case, but it's difficult. I haven't
> fully understood the reason why it sometimes crashes and sometimes not.
>
> The smallest I could come up with so far is something like this:
>
> CREATE TABLE crash (
> hostname varchar,
> hostname_short varchar GENERATED ALWAYS AS (hostname) STORED,
> device text,
> mount text,
> used_space_bytes bigint,
> avail_space_bytes bigint
> );
> INSERT INTO crash (hostname, device, mount, used_space_bytes,
> avail_space_bytes) VALUES (repeat('1234567890', 100), 'devtmpfs',
> '/dev', 0, 6047076131313);
>
> Would this be easier to reproduce with one of the memory-cleaning
> #defines enabled?
I've done a bit more work on this and have something close. The case I
came up with for it was:
+CREATE TABLE gtest_varlena (a varchar, b varchar GENERATED ALWAYS AS
(a) STORED);
+INSERT INTO gtest_varlena (a) VALUES('01234567890123456789');
+INSERT INTO gtest_varlena (a) VALUES(NULL);
+SELECT * FROM gtest_varlena ORDER BY a;
+ a | b
+----------------------+----------------------
+ 01234567890123456789 | 01234567890123456789
+ |
+(2 rows)
+
+DROP TABLE gtest_varlena;
With that, on an unpatched server, there's no crash, but there's
clearly junk in the b column.
Commits
-
Fix possible crash with GENERATED ALWAYS columns
- a375f11c44cf 12.3 landed
- 3cb02e307e35 13.0 landed