Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ab8ZZ-00056x-Hr for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Mar 2016 15:20:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ab8ZY-0005RD-Qx for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Mar 2016 15:20:20 +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 1ab8YD-0003qQ-Su for pgsql-hackers@postgresql.org; Wed, 02 Mar 2016 15:18:58 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ab8Y9-0001YT-KV for pgsql-hackers@postgresql.org; Wed, 02 Mar 2016 15:18:56 +0000 Received: by mail-wm0-x234.google.com with SMTP id l68so84986018wml.0 for ; Wed, 02 Mar 2016 07:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=nfkDPfgnQL2xNXs1Ie/u35h2kOff454fYZPVVp0R1r0=; b=gfAzSP+aE7pE0WHkzg0IoSo0mShSX+MVnfQjtvdMk6MkSSI/g5wvIjrIw8eOeXS4ZM Q1cmmyJrH4p8yDK+PfUQ2uXAx1pKuw6fpyWiv5Kujlb3es6w9YH6R4erNLPwjJUUgcrP OPcCStCSGFE8wPdydOaRdwBWDFg1KCXgw1GpukXf1X2uxkYJ4IYPfMDqPxzx0b5CAoaG vjRG0BAxNjswiKpzibf79N6k2+mCh+v/ueMzw9eOi/wO2HbObaugHPwbB40d++QqovzJ K4DHHYjftcgZm7gEh+/32YjdRls3sDsGZYmzmhw91ar/PB7CSciGCXRmcqEO8g2YBqEO /tWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=nfkDPfgnQL2xNXs1Ie/u35h2kOff454fYZPVVp0R1r0=; b=kwcXfJ/JBJwuM82GRJJnfB+m0BsH9QCHBHskrAFmL2dRojVqxjff4Puule2JVc9AXv rM7KC2zCYYVUVKD/7FyGekoqaDKG5nZF5qHAY3/VeVjvAdBqQWvVdfDW2Ot366K4z9VY Q/3jUSj+O+l5Q+9ZfuuLEWZNE3gaVcx7I+GzHW4B+E+26oVOPclsERZDaS3cdI+r3PxN w+hBPHuQOc5pLVqa9DiKu9jYViQ1pItEUgG+5GKRlJHygUPkwm/qiZHRKV0FWI92LTxM bZANFrgSMF32HUO/Qt1UdO3GU2vs2NWSodXhmgUSKi5+QjsLqNHiuMz/b90Sm3GA5AI4 evsA== X-Gm-Message-State: AD7BkJL8QKo9ZAvQgSdKqNuUCx48CU3tKnt8W0u3jgzy5KerDyimJ2P24z4ameSHw+TQa4HBFWXW4Hajps/ry5p8s9sPlmIC3Sv+WNAnBB2crMLKPtnO05b8n62pFKQ1bY655+qYs4wivlg+yikFC9L5+alTiOGhLxAoUvDQpCRnuqyMD8ho7VzwDEJGz7NSI5k6ufy689Ol X-Received: by 10.28.171.8 with SMTP id u8mr400662wme.97.1456931931857; Wed, 02 Mar 2016 07:18:51 -0800 (PST) Received: from [10.137.1.13] (ip-78-45-216-26.net.upcbroadband.cz. [78.45.216.26]) by smtp.gmail.com with ESMTPSA id gb9sm36387725wjb.26.2016.03.02.07.18.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 07:18:50 -0800 (PST) Subject: Re: pg_dump / copy bugs with "big lines" ? To: pgsql-hackers@postgresql.org References: <10cb3300-67ab-4d3b-a930-7106d4dbac04@mm> From: Tomas Vondra Message-ID: <56D70458.2010006@2ndquadrant.com> Date: Wed, 2 Mar 2016 16:18:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <10cb3300-67ab-4d3b-a930-7106d4dbac04@mm> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 Hi, On 03/02/2016 03:18 PM, Daniel Verite wrote: > I wrote: > >> postgres=# \copy big2 to /dev/null >> lost synchronization with server: got message type "d", length -1568669676 >> >> The backend aborts with the following backtrace: >> >> Program terminated with signal 6, Aborted. >> #0 0x00007f82ee68e165 in raise () from /lib/x86_64-linux-gnu/libc.so.6 >> #1 0x00007f82ee6913e0 in abort () from /lib/x86_64-linux-gnu/libc.so.6 >> #2 0x00007f82ee6c839b in ?? () from /lib/x86_64-linux-gnu/libc.so.6 >> #3 0x00007f82ee6d1be6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 >> #4 0x00007f82ee6d698c in free () from /lib/x86_64-linux-gnu/libc.so.6 >> #5 0x00000000007b5a89 in AllocSetDelete (context=0xffffffffffffffff) >> at aset.c:643 >> #6 0x00000000007b63e3 in MemoryContextDelete (context=0x1fa58c8) at >> mcxt.c:229 >> #7 0x000000000055fa25 in CopyTo (cstate=0x1fb1050) at copy.c:1967 > > 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. > > 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. My guess is this is a problem at the protocol level - the 'd' message is CopyData, and all the messages use int32 to define length. So if there's a 2GB row, it's likely to overflow. regards -- Tomas Vondra 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