Skip site navigation (1) Skip section navigation (2)

fatal flex error in guc-file.l kills the postmaster

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: fatal flex error in guc-file.l kills the postmaster
Date: 2011-12-16 17:22:58
Message-ID: 20111216172258.GA4045@tornado.leadboat.com (view raw or flat)
Thread:
Lists: pgsql-bugs
While testing the configuration include directory patch, I decided to try
the regular postgresql.conf "include" on a directory:

  include 'base'

Reloading the configuration then rather rudely kills the postmaster:

  FATAL:  input in flex scanner failed

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.

It seems plainly hackish to mutate the body of yy_fatal_error() by #define'ing
fprintf().  Why didn't we instead #define YY_FATAL_ERROR and provide our own
complete replacement?  (Both strategies are undocumented.)  I haven't changed
that decision in this patch, though.

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.  guc.c has functions
like guc_malloc that handle variable elevels.  However, various check_* and
assign_* functions, such as check_log_destination(), use pstrdup() and
guc_malloc(ERROR).  Failing there during a reload would also kill the
postmaster.  Is it worth doing better here?

Incidentally, the wal writer process no longer exits promptly on postmaster
death.  I didn't look into that further.

Thanks,
nm

Responses

pgsql-bugs by date

Next:From: Craig RingerDate: 2011-12-17 06:19:14
Subject: Re: R: BUG #6342: libpq blocks forever in "poll" function
Previous:From: Pavel HolecDate: 2011-12-16 16:39:46
Subject: Re: user names & non-ASCII

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group