Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ab9DX-0007Oa-Vk for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Mar 2016 16:01:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ab9DX-0001hs-0E for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Mar 2016 16:01:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ab9DV-0001h0-Tz for pgsql-hackers@postgresql.org; Wed, 02 Mar 2016 16:01:38 +0000 Received: from out.smtp-auth.no-ip.com ([8.23.224.60]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ab9DS-0002V6-Nm for pgsql-hackers@postgresql.org; Wed, 02 Mar 2016 16:01:36 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [181.42.169.78]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id C9629400DF0; Wed, 2 Mar 2016 08:01:30 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 8A2F4994; Wed, 2 Mar 2016 12:47:17 -0300 (CLT) Date: Wed, 2 Mar 2016 12:47:17 -0300 From: Alvaro Herrera To: Daniel Verite Cc: Robert Haas , Jim Nasby , Ronan Dunklau , pgsql-hackers Subject: Re: pg_dump / copy bugs with "big lines" ? Message-ID: <20160302154717.GA422573@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <10cb3300-67ab-4d3b-a930-7106d4dbac04@mm> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Daniel Verite wrote: > The cause of the crash turns out to be, in enlargeStringInfo(): > > needed += str->len + 1; /* total space required now */ > > needed is an int and str->len is an int64, so it overflows when the > size has to grow beyond 2^31 bytes, fails to enlarge the buffer and > overwrites memory after it. > > When fixing it with a local int64 copy of the variable, the backend > no longer crashes and COPY big2 TO 'file' appears to work. Great, thanks for debugging. > However, getting it to the client with \copy big2 to 'file' > still produces the error in psql: > lost synchronization with server: got message type "d" > and leaves an empty file, so there are more problems to solve to > go beyond 2GB text per row. Well, the CopyData message has an Int32 field for the message length. I don't know the FE/BE protocol very well but I suppose each row corresponds to one CopyData message, or perhaps each column corresponds to one CopyData message. In either case, it's not possible to go beyond 2GB without changing the protocol ... -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers