Subject: RE: WIP: System Versioned Temporal Table

From: [email-masked]
Date: Thu, 04 Feb 2021 13:43:11 +0100

hi,

i tested the temporal patch ( https://commitfest.postgresql.org/26/2316/ ) with the current 14devel applied ontop of ef3d461 without any conflicts.
i build with no special options passed to ./configure and noticed, that the postgresql-client-13 from the debian repositories crashes with the \d command

to reproduce the issue:

  CREATE TABLE test (
    id int PRIMARY KEY generated ALWAYS AS IDENTITY,
    name text NOT NULL,
    start_timestamp timestamp with time zone GENERATED ALWAYS AS ROW START,
    end_timestamp timestamp with time zone GENERATED ALWAYS AS ROW END,
    PERIOD FOR SYSTEM_TIME (start_timestamp, end_timestamp)
  );

  \d test

it failes after outputting the table informations with this backtrace:

  free(): invalid pointer
  [1]    587783 abort (core dumped)  psql -X -U easteregg -h localhost postgres

  (gdb) bt 50
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x00007f21a62e0537 in __GI_abort () at abort.c:79
  #2  0x00007f21a6339768 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f21a6447e31 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
  #3  0x00007f21a6340a5a in malloc_printerr (str=str@entry=0x7f21a644605e "free(): invalid pointer") at malloc.c:5347
  #4  0x00007f21a6341c14 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:4173
  #5  0x000055c9fa47b602 in printTableCleanup (content=content@entry=0x7ffece7e41c0) at ./build/../src/fe_utils/print.c:3250
  #6  0x000055c9fa444aa3 in describeOneTableDetails (schemaname=<optimized out>, schemaname@entry=0x55c9fbebfee6 "public", relationname=<optimized out>, oid=oid@entry=0x55c9fbebfee0 "16436", verbose=verbose@entry=false) at ./build/../src/bin/psql/describe.c:3337
  #7  0x000055c9fa4490c9 in describeTableDetails (pattern=pattern@entry=0x55c9fbebf540 "abk", verbose=verbose@entry=false, showSystem=<optimized out>) at ./build/../src/bin/psql/describe.c:1421
  #8  0x000055c9fa4372ff in exec_command_d (scan_state=scan_state@entry=0x55c9fbebd130, active_branch=active_branch@entry=true, cmd=cmd@entry=0x55c9fbebf430 "d") at ./build/../src/bin/psql/command.c:722
  #9  0x000055c9fa43ae2b in exec_command (previous_buf=0x55c9fbebd3a0, query_buf=0x55c9fbebd270, cstack=0x55c9fbebd250, scan_state=0x55c9fbebd130, cmd=0x55c9fbebf430 "d") at ./build/../src/bin/psql/command.c:317
  #10 HandleSlashCmds (scan_state=scan_state@entry=0x55c9fbebd130, cstack=cstack@entry=0x55c9fbebd250, query_buf=0x55c9fbebd270, previous_buf=0x55c9fbebd3a0) at ./build/../src/bin/psql/command.c:220
  #11 0x000055c9fa4539e0 in MainLoop (source=0x7f21a6479980 <_IO_2_1_stdin_>) at ./build/../src/bin/psql/mainloop.c:502
  #12 0x000055c9fa433d64 in main (argc=<optimized out>, argv=0x7ffece7e47f8) at ./build/../src/bin/psql/startup.c:441

the client is this version:

  apt-cache policy postgresql-client-13
  postgresql-client-13:
    Installed: 13.1-1.pgdg+2+b3
    Candidate: 13.1-1.pgdg+2+b3
    Version table:
   *** 13.1-1.pgdg+2+b3 100
          100 http://apt.postgresql.org/pub/repos/apt sid-pgdg-testing/main amd64 Packages
          100 /var/lib/dpkg/status

the the 14devel version from my build or a selfcompiled REL_13_STABLE client will not crash.
i was wondering if this might pose a security concern.

i am a bit out of my depths here, but would be glad to help, if any informations are missing
with kind regards, 
richard