Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVxyh-0006YI-C8 for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Aug 2016 09:33:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bVxyf-0008Po-Ut for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Aug 2016 09:33:09 +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_2) (envelope-from ) id 1bVxyd-0008OT-0J for pgsql-hackers@postgresql.org; Sat, 06 Aug 2016 09:33:07 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bVxyV-0005w7-7o for pgsql-hackers@postgresql.org; Sat, 06 Aug 2016 09:33:05 +0000 Received: from gauss.credativ.com (localhost [127.0.0.1]) by gauss.credativ.com (Postfix) with ESMTP id 3DA9C1B44DD; Sat, 6 Aug 2016 11:32:55 +0200 (CEST) Received: from ex (ip-109-44-3-112.web.vodafone.de [109.44.3.112]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: ase@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id B49201B44DC for ; Sat, 6 Aug 2016 11:32:54 +0200 (CEST) From: Andreas Seltenreich To: pgsql-hackers@postgresql.org Subject: [sqlsmith] Crash in GetOldestSnapshot() User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux) Message-ID: <87vazemeda.fsf@credativ.de> Date: Sat, 06 Aug 2016 11:32:49 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -1.9 (-) 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, since updating master from c93d873..fc509cd, I see crashes in GetOldestSnapshot() on update/delete returning statements. I reduced the triggering statements down to this: update clstr_tst set d = d returning d; Backtrace below. regards, Andreas Program received signal SIGSEGV, Segmentation fault. (gdb) bt #0 GetOldestSnapshot () at snapmgr.c:422 #1 0x00000000004b8279 in init_toast_snapshot (toast_snapshot=0x7ffcd824b010) at tuptoaster.c:2314 #2 0x00000000004b83bc in toast_fetch_datum (attr=) at tuptoaster.c:1869 #3 0x00000000004b9ab5 in heap_tuple_untoast_attr (attr=0x18226c8) at tuptoaster.c:179 #4 0x00000000007f71ad in pg_detoast_datum_packed (datum=) at fmgr.c:2266 #5 0x00000000007cfc12 in text_to_cstring (t=0x18226c8) at varlena.c:186 #6 0x00000000007f5735 in FunctionCall1Coll (flinfo=flinfo@entry=0x18221c0, collation=collation@entry=0, arg1=arg1@entry=25306824) at fmgr.c:1297 #7 0x00000000007f68ee in OutputFunctionCall (flinfo=0x18221c0, val=25306824) at fmgr.c:1946 #8 0x0000000000478bc1 in printtup (slot=0x1821f80, self=0x181ce48) at printtup.c:359 #9 0x00000000006f9c8e in RunFromStore (portal=portal@entry=0x177cbf8, direction=direction@entry=ForwardScanDirection, count=count@entry=0, dest=0x181ce48) at pquery.c:1117 #10 0x00000000006f9d52 in PortalRunSelect (portal=portal@entry=0x177cbf8, forward=forward@entry=1 '\001', count=0, count@entry=9223372036854775807, dest=dest@entry=0x181ce48) at pquery.c:942 #11 0x00000000006fb41e in PortalRun (portal=portal@entry=0x177cbf8, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001', dest=dest@entry=0x181ce48, altdest=altdest@entry=0x181ce48, completionTag=completionTag@entry=0x7ffcd824b920 "") at pquery.c:787 #12 0x00000000006f822b in exec_simple_query (query_string=0x17db878 "update clstr_tst set d = d returning d;") at postgres.c:1094 #13 PostgresMain (argc=, argv=argv@entry=0x1781ce0, dbname=0x1781b40 "regression", username=) at postgres.c:4074 #14 0x000000000046c9bd in BackendRun (port=0x1786920) at postmaster.c:4262 #15 BackendStartup (port=0x1786920) at postmaster.c:3936 #16 ServerLoop () at postmaster.c:1693 #17 0x0000000000693044 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x175d5f0) at postmaster.c:1301 #18 0x000000000046dd26 in main (argc=3, argv=0x175d5f0) at main.c:228 (gdb) list 417 418 if (OldestActiveSnapshot != NULL) 419 ActiveLSN = OldestActiveSnapshot->as_snap->lsn; 420 421 if (XLogRecPtrIsInvalid(RegisteredLSN) || RegisteredLSN > ActiveLSN) 422 return OldestActiveSnapshot->as_snap; 423 424 return OldestRegisteredSnapshot; 425 } 426 (gdb) bt full #0 GetOldestSnapshot () at snapmgr.c:422 OldestRegisteredSnapshot = RegisteredLSN = ActiveLSN = #1 0x00000000004b8279 in init_toast_snapshot (toast_snapshot=0x7ffcd824b010) at tuptoaster.c:2314 snapshot = #2 0x00000000004b83bc in toast_fetch_datum (attr=) at tuptoaster.c:1869 toastrel = 0x7f8b4ca88920 toastidxs = 0x18447c8 toastkey = { sk_flags = 0, sk_attno = 1, sk_strategy = 3, sk_subtype = 0, sk_collation = 100, sk_func = { fn_addr = 0x77c490 , fn_oid = 184, fn_nargs = 2, fn_strict = 1 '\001', fn_retset = 0 '\000', fn_stats = 2 '\002', fn_extra = 0x0, fn_mcxt = 0x18282a8, fn_expr = 0x0 }, sk_argument = 34491 } toastscan = ttup = toasttupDesc = 0x7f8b4ca88c50 result = 0x18422d8 toast_pointer = ressize = 5735 residx = nextidx = 0 numchunks = 3 chunk = isnull = chunkdata = chunksize = num_indexes = 1 validIndex = 0 SnapshotToast = { satisfies = 0x112, xmin = 3626283536, xmax = 32764, xip = 0xf8ac628, xcnt = 5221870, subxip = 0x0, subxcnt = 0, suboverflowed = 0 '\000', takenDuringRecovery = 0 '\000', copied = 0 '\000', curcid = 14, speculativeToken = 0, active_count = 260753304, regd_count = 0, ph_node = { first_child = 0xf8ac680, next_sibling = 0xa40000000000112, prev_or_parent = 0x0 }, whenTaken = 274, lsn = 0 } __func__ = "toast_fetch_datum" #3 0x00000000004b9ab5 in heap_tuple_untoast_attr (attr=0x18226c8) at tuptoaster.c:179 No locals. #4 0x00000000007f71ad in pg_detoast_datum_packed (datum=) at fmgr.c:2266 No locals. #5 0x00000000007cfc12 in text_to_cstring (t=0x18226c8) at varlena.c:186 tunpacked = result = #6 0x00000000007f5735 in FunctionCall1Coll (flinfo=flinfo@entry=0x18221c0, collation=collation@entry=0, arg1=arg1@entry=25306824) at fmgr.c:1297 fcinfo = { flinfo = 0x18221c0, context = 0x0, resultinfo = 0x0, fncollation = 0, isnull = 0 '\000', nargs = 1, arg = {25306824, 6868497, 0, 25356976, 1966, 1966, 0, 25207736, 1966, 8470236, 1966, 1966, 140236265213248, 7113528, 0, 4, 1, 25358272, 0, 309237645256, 140236281446912, 1966, 25349336, 25207736, 1966, 8470236, 1966, 1966, 140236265213248, 7113605, 47, 148110127398913, 25346992, 25358272, 25346992, 1, 25348352, 6188273, 3689292519771913624, 140723934769840, 140723934770607, 140723934769840, 0, 10024654, 140723934770200, 0, 140723934770544, 140236311507497, 4222418944, 140723934770544, 0, 8226869, 0, 140236263291992, 25, 140723934769968, 24856000, 8232733, 140236263291992, 15294443587, 25, 140723934770016, 1125891316908032, 0, 7849104, 281483566645432, 2, 0, 24651624, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 8192, 8240, 128, 755914244609, 16, 2, 481036337259, 0, 0, 532575944823, 0, 140236314839840, 8192, 1024, 8192, 0, 25304960, 140236311549156}, argnull = "\000\000\000\000\000\000\000\000\250\202\202\001\000\000\000\000\250\202\202\001\000\000\000\000p\203\202\001\000\000\000\000\000\004\000\000\000\000\000\000\000\004\000\000\000\000\000\000\360\264$\330\374\177\000\000H\316\201\001\000\000\000\000\b\261\200\001\000\000\000\000\002\000\000\000\000\000\000\000\360\264$\330\374\177\000\000\033\314`\000\000\000\000\000\000\000\000" } result = __func__ = "FunctionCall1Coll" #7 0x00000000007f68ee in OutputFunctionCall (flinfo=0x18221c0, val=25306824) at fmgr.c:1946 result = pushed = 0 '\000' #8 0x0000000000478bc1 in printtup (slot=0x1821f80, self=0x181ce48) at printtup.c:359 outputstr = thisState = attr = typeinfo = myState = 0x181ce48 oldcontext = 0x180b108 buf = { data = 0x182aac8 "", len = 2, maxlen = 1024, cursor = 68 } natts = 1 i = 0 #9 0x00000000006f9c8e in RunFromStore (portal=portal@entry=0x177cbf8, direction=direction@entry=ForwardScanDirection, count=count@entry=0, dest=0x181ce48) at pquery.c:1117 oldcontext = 0x180b108 ok = forward = 1 '\001' current_tuple_count = 14 slot = 0x1821f80 #10 0x00000000006f9d52 in PortalRunSelect (portal=portal@entry=0x177cbf8, forward=forward@entry=1 '\001', count=0, count@entry=9223372036854775807, dest=dest@entry=0x181ce48) at pquery.c:942 queryDesc = 0x0 direction = nprocessed = __func__ = "PortalRunSelect" #11 0x00000000006fb41e in PortalRun (portal=portal@entry=0x177cbf8, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001', dest=dest@entry=0x181ce48, altdest=altdest@entry=0x181ce48, completionTag=completionTag@entry=0x7ffcd824b920 "") at pquery.c:787 save_exception_stack = 0x7ffcd824b9a0 save_context_stack = 0x0 local_sigjmp_buf = {{ __jmpbuf = {25020000, 8117249591578047072, 25020088, 2, 25284168, 24503472, -8115502085312499104, 8117247189865575008}, __mask_was_saved = 0, __saved_mask = { __val = {8368164, 1, 24911592, 10273694, 2, 1, 2, 140723934771202, 88, 24628216, 25020088, 2, 8459620, 25020000, 2, 24628216} } }} result = nprocessed = saveTopTransactionResourceOwner = 0x1782df8 saveTopTransactionContext = 0x175e4b0 saveActivePortal = 0x0 saveResourceOwner = 0x1782df8 savePortalContext = 0x0 saveMemoryContext = 0x175e4b0 __func__ = "PortalRun" #12 0x00000000006f822b in exec_simple_query (query_string=0x17db878 "update clstr_tst set d = d returning d;") at postgres.c:1094 parsetree = 0x17dc660 portal = 0x177cbf8 snapshot_set = commandTag = completionTag = "\000ELECT 1\000\377\377\177", '\000' , "\240\364\272O\213\177\000\000\000\000\000\000\000\000\000\000\"\000\000\000\000\000\000\000\330\367u\001\000\000\000\000\310\327u\001\000\000\000" querytree_list = plantree_list = receiver = 0x181ce48 format = 0 dest = DestRemote parsetree_list = 0x17dc6e0 save_log_statement_stats = 0 '\000' was_logged = 0 '\000' msec_str = "\310\317$\330\374\177", '\000' parsetree_item = 0x17dc6b8 isTopLevel = 1 '\001' #13 PostgresMain (argc=, argv=argv@entry=0x1781ce0, dbname=0x1781b40 "regression", username=) at postgres.c:4074 query_string = 0x17db878 "update clstr_tst set d = d returning d;" firstchar = 25020000 input_message = { data = 0x17db878 "update clstr_tst set d = d returning d;", len = 40, maxlen = 1024, cursor = 40 } local_sigjmp_buf = {{ __jmpbuf = {24648928, 8117247467474629216, 24648480, 0, 0, 24636608, -8115502085385899424, 8117247183479878240}, __mask_was_saved = 1, __saved_mask = { __val = {0, 24648856, 24648480, 24648512, 1024, 140723934771904, 24648928, 0, 8459304, 24632953, 8454626, 13256160, 140723934771904, 24648928, 8376332, 24633416} } }} send_ready_for_query = 0 '\000' disable_idle_in_transaction_timeout = __func__ = "PostgresMain" -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers