aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-09-05 16:43:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-09-05 16:43:41 -0400
commit8e6f6b8ef2b990712d999f2f32c610376c1ebf57 (patch)
treef0e1618526896a9526b6f4ed4496ffed3fa71524
parent970212f911728097b44ac231438c5cf4d45b2089 (diff)
downloadpostgresql-8e6f6b8ef2b990712d999f2f32c610376c1ebf57.tar.gz
postgresql-8e6f6b8ef2b990712d999f2f32c610376c1ebf57.zip
Restore SIGFPE handler after initializing PL/Perl.
Perl, for some unaccountable reason, believes it's a good idea to reset SIGFPE handling to SIG_IGN. Which wouldn't be a good idea even if it worked; but on some platforms (Linux at least) it doesn't work at all, instead resulting in forced process termination if the signal occurs. Given the lack of other complaints, it seems safe to assume that Perl never actually provokes SIGFPE and so there is no value in the setting anyway. Hence, reset it to our normal handler after initializing Perl. Report, analysis and patch by Andres Freund.
-rw-r--r--src/pl/plperl/plperl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index db584c4e7e4..868552d6caa 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -23,11 +23,13 @@
#include "commands/trigger.h"
#include "executor/spi.h"
#include "funcapi.h"
+#include "libpq/pqsignal.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "storage/ipc.h"
+#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
@@ -741,6 +743,18 @@ plperl_init_interp(void)
char *dummy_env[1] = {NULL};
PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char ***) &dummy_env);
+
+ /*
+ * For unclear reasons, PERL_SYS_INIT3 sets the SIGFPE handler to
+ * SIG_IGN. Aside from being extremely unfriendly behavior for a
+ * library, this is dumb on the grounds that the results of a
+ * SIGFPE in this state are undefined according to POSIX, and in
+ * fact you get a forced process kill at least on Linux. Hence,
+ * restore the SIGFPE handler to the backend's standard setting.
+ * (See Perl bug 114574 for more information.)
+ */
+ pqsignal(SIGFPE, FloatExceptionHandler);
+
perl_sys_init_done = 1;
/* quiet warning if PERL_SYS_INIT3 doesn't use the third argument */
dummy_env[0] = NULL;