Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z8WbR-0003Ip-Dg for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jun 2015 16:35:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z8WbQ-0000wq-Ok for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jun 2015 16:35:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8Wab-0000CG-BU for pgsql-bugs@postgresql.org; Fri, 26 Jun 2015 16:34:53 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z8WaY-0007D8-KY for pgsql-bugs@postgresql.org; Fri, 26 Jun 2015 16:34:52 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 1DA0A860002; Fri, 26 Jun 2015 18:34:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, FB_REPLIC_CAP,FS_REPLICA autolearn=no version=3.2.5 Received: from anarazel.de (p5DDC6AF3.dip0.t-ipconnect.de [93.220.106.243]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id C8959860001; Fri, 26 Jun 2015 18:34:46 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 5A1EA101877; Fri, 26 Jun 2015 18:34:46 +0200 (CEST) Date: Fri, 26 Jun 2015 18:34:46 +0200 From: Andres Freund To: kotlarski.krzysztof@gmail.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13470: Logical replication 'invalid memory alloc' Message-ID: <20150626163446.GB19129@awork2.anarazel.de> References: <20150626100333.3874.90852@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150626100333.3874.90852@wrigleys.postgresql.org> X-Pg-Spam-Score: -5.6 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, On 2015-06-26 10:03:33 +0000, kotlarski.krzysztof@gmail.com wrote: > Minimal reproductible example: > > SELECT * FROM pg_create_logical_replication_slot('test_slot', > 'test_decoding'); > CREATE TABLE "t" ("a" character varying); > ALTER TABLE "t" REPLICA IDENTITY FULL; > INSERT INTO "t" ("a") VALUES ('a1'); > ALTER TABLE "t" ADD "b" character varying; > UPDATE "t" SET "a" = 'a2'; > SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL); > > Produces: > ERROR: invalid memory alloc request size 18446744073709551613 > CONTEXT: slot "test_slot", output plugin "test_decoding", in the change > callback, associated LSN 6/BD3D8C28 Ick. The problem is that I used fastgetattr() in test_decoding's tuple_to_stringinfo(). Which is normally ok, even though fragile, because the new tuple's natts will always be tupledesc->natts. !FULL replica identities can't contain nulls for pretty much the same reason. But with FULL the *old*, preexisting, tuple will be logged - which can have a lower natts value. So this should just be a heap_getattr(), not a fastgetattr(). The next set of backbranch releases will contain the fix, until then you could just fix it in test_decoding.c (or the plugin I guess you copied the code to?). Greetings, Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs