Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2200317E0CF5 for ; Sun, 18 Dec 2011 00:05:01 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rc7ze-0006PE-39 for pgsql-bugs@postgresql.org; Sun, 18 Dec 2011 04:05:00 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pBI44iOh021050; Sat, 17 Dec 2011 23:04:44 -0500 (EST) To: Noah Misch cc: pgsql-bugs@postgresql.org Subject: Re: fatal flex error in guc-file.l kills the postmaster In-reply-to: <20111216172258.GA4045@tornado.leadboat.com> References: <20111216172258.GA4045@tornado.leadboat.com> Comments: In-reply-to Noah Misch message dated "Fri, 16 Dec 2011 12:22:58 -0500" Date: Sat, 17 Dec 2011 23:04:43 -0500 Message-ID: <21049.1324181083@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -4.1 (----) X-Archive-Number: 201112/137 X-Sequence-Number: 31948 Noah Misch writes: > Setting aside whether we should offer a better diagnostic when a user points > "include" at a directory, the yy_fatal_error hack that made sense for scan.l > doesn't cut it for guc-file.l. Like other guc-file.l errors, we need to > choose the elevel based on which process is running the code. ERROR is never > the right choice. We should instead stash the message, longjmp out of the > flex parser, and proceed to handle the error mostly like a regular syntax > error. See attached small patch. Well, if you're going to criticize the original method as being hackish, you really need to offer a cleaner substitute than this one ;-). In particular I'm not happy with adding a sigsetjmp() cycle for every single token parsed. > It seems plainly hackish to mutate the body of yy_fatal_error() by #define'ing > fprintf(). I agree, but the flex boys haven't provided any nicer API ... at least not unless we'd like to convert to C++. > Why didn't we instead #define YY_FATAL_ERROR and provide our own > complete replacement? For one reason, yy_fatal_error would still be there and would draw an "unused static function" warning. > On a related note, the out-of-memory handling during config file reload is > inconsistent. guc-file.l uses palloc/pstrdup in various places. An OOM at > those sites during a reload would kill the postmaster. If you've got OOM in the postmaster, you're dead anyway. I feel no compulsion to worry about this. regards, tom lane