Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lS1Yg-000714-Kg for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Apr 2021 17:56:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lS1Ye-0007TI-RP for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Apr 2021 17:56:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lS1Ye-0007TB-Gv for pgsql-bugs@lists.postgresql.org; Thu, 01 Apr 2021 17:56:40 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lS1Yb-0004D2-8X for pgsql-bugs@lists.postgresql.org; Thu, 01 Apr 2021 17:56:39 +0000 Received: by mail-il1-x12a.google.com with SMTP id y17so2759760ila.6 for ; Thu, 01 Apr 2021 10:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ovtOYifWvBtRcWs4qZSkcwWGeoX29/c+4YhMHRgWCKU=; b=Ard9ytuBFYn2FLeHnfZNz2xca+1EwsdjqoQ11j6aVk+bMmeAdJc5jF9kvLRHBHDhD0 9TFtFLGdJQzbO6I51HNxaujvjIs65RFF01fYCYFbXY3z4bYaS3bnVGEjWZBvp8USsIEh O1P8cgpPv76Rf42Fc+sZqZFLeeJDtoLhpFLPm/LdVPpgAFbGSXzTkxtxMJy5vlROgdD6 ARfNjezpeKoNxkfpfkIM6Bniqz3WnaUf5lPgPM2CbccM1BNgribr9noutaJo6vsjl6aN UyFEmciVlIM2s26nB2rYLO66eURzrm6Tkr4afXald/JggHDZpQzk3cxTKVMT2nMHL9CL rjdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ovtOYifWvBtRcWs4qZSkcwWGeoX29/c+4YhMHRgWCKU=; b=a/UR03s8JqiJxLsud5Wj2IvmwSMYpksnyF7Egtu9auTytOx6LMWan9mkc6yawOSQmx xT8ogCoRe9y92ckaG/e7ZwlcSVXS+0jlQi1LduNUPm1DdFpw8Cm6sBacsafHxHp6ypTa kTa7oHeDfTOS43j5eedZCOdh10wMHCJDVkSLXVDtCSgC8M9ob+C10Bmq4FKUQMA2d5zd Y0y2avN3OWDlaa/jsb7TFTSXmgKYPlMSBTbRycyOb+zm0afAoRu+uhYDE6aa7om03klw dQGZdR+BDs4M+CZU3cY/yn58LbGPf7ul6mAxpVLU8JMoeB7QMo/TUNtzQ8Qv2z9WO7+Y ChhA== X-Gm-Message-State: AOAM530PDvXZ2jXpOYOM5QjnTkbLs1/+Fdxn5zc4wINFZeBOO8NV08B9 wOW5slpmjnapOx8MxYKVeADDDA== X-Google-Smtp-Source: ABdhPJwcqleqc+9A/MtHWU0LAAQjjGmU8Xc0zI21O0oSD6pWp+PF6mlVNakFuk1VG6KUM2QwtUIvSg== X-Received: by 2002:a92:ac04:: with SMTP id r4mr1895938ilh.99.1617299796260; Thu, 01 Apr 2021 10:56:36 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k6sm2894561ili.12.2021.04.01.10.56.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Apr 2021 10:56:35 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id C48338008D1; Thu, 1 Apr 2021 12:56:34 -0500 (CDT) Date: Thu, 1 Apr 2021 12:56:34 -0500 From: Justin Pryzby To: Tom Lane Cc: Sergey KOPOSOV , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG Message-ID: <20210401175634.GI4431@telsasoft.com> References: <16951-a4dd68cf0de23048@postgresql.org> <3331060.1617226031@sss.pgh.pa.us> <5d848bddbb3b6421af5a742e36ede542e719c492.camel@ed.ac.uk> <3338139.1617230824@sss.pgh.pa.us> <51cec7215378e9beccb9b58831f6e0a2be30bd06.camel@ed.ac.uk> <3413025.1617291573@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3413025.1617291573@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 01, 2021 at 11:39:33AM -0400, Tom Lane wrote: > Sergey KOPOSOV writes: > > Importantly This requires running pg_restore without '-Fc' flag, i.e. to let it autodetect. > > > $ cat /tmp/xx1.short | ./src/bin/pg_dump/pg_restore > > Segmentation fault (core dumped) > > $ cat /tmp/xx1.short | ./src/bin/pg_dump/pg_restore -Fc > > pg_restore: [archiver] unsupported version (1.14) in file header > > Ooooh ... the autodetect + cant-seek code path is just broken. All of the > sanity checks on the first few fields of the file --- particularly the > version number --- just get skipped in this scenario. > > I wonder why it's a good idea to read-ahead any of those fields in the > first place. Checking the PGDMP magic string seems sufficient. > > Will fix, thanks for the report! Yes, thank you both. I've run into this recently but for some reason I thought it was fixed. It probably also explains this one from 2014. https://www.postgresql.org/message-id/20141206061151.GA725@telsasoft.com -- Justin