Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TCHAl-0001jo-Lo for pgsql-bugs@postgresql.org; Thu, 13 Sep 2012 21:42:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TCHAj-0000cq-Mg for pgsql-bugs@postgresql.org; Thu, 13 Sep 2012 21:42:07 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q8DLg2Pb022391; Thu, 13 Sep 2012 17:42:03 -0400 (EDT) From: Tom Lane To: Marko Tiikkaja cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7516: PL/Perl crash In-reply-to: <21173.1347568661@sss.pgh.pa.us> References: <1194.1346688396@sss.pgh.pa.us> <5047BA9C.2040405@joh.to> <16153.1347226320@sss.pgh.pa.us> <17785.1347230278@sss.pgh.pa.us> <504F8034.20802@joh.to> <4011.1347407415@sss.pgh.pa.us> <50506B94.5040003@joh.to> <17684.1347558484@sss.pgh.pa.us> <505229E8.9070507@joh.to> <21173.1347568661@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 13 Sep 2012 16:37:41 -0400" Date: Thu, 13 Sep 2012 17:42:02 -0400 Message-ID: <22390.1347572522@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) X-Archive-Number: 201209/127 X-Sequence-Number: 34122 I wrote: > Apparently the reasoning is that current_call_data is a static and > therefore the compiler can see everything that can happen to it and > therefore this store into current_call_data is dead code, since the > store six lines below will replace it. Sigh. I shall file a bug, > but I've found that the current crop of gcc maintainers are quite > likely to reject such reports. Filed at https://bugzilla.redhat.com/show_bug.cgi?id=857236 On the good side: developing a minimal test case showed me that the code is incorrectly compiled only if perl.h has been included. (WTF? No, I don't know why.) So at least this gcc bug should only be affecting plperl.c and not the rest of postgres. > We could fix the immediate problem by marking current_call_data volatile > (I've tested that this makes the problem go away on F17), but I think > what we'd better do instead is mark pg_re_throw() as noreturn. > Hopefully that will also prevent this misoptimization, as well as > similar ones that might be happening elsewhere. But, of course, pg_re_throw() already is marked noreturn. A probably less costly solution than marking current_call_data volatile is just to make it not-static. regards, tom lane