Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 28ab4a5

Browse files
committed
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.
1 parent b98fd52 commit 28ab4a5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/pl/plperl/plperl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
#include "commands/trigger.h"
2525
#include "executor/spi.h"
2626
#include "funcapi.h"
27+
#include "libpq/pqsignal.h"
2728
#include "mb/pg_wchar.h"
2829
#include "miscadmin.h"
2930
#include "nodes/makefuncs.h"
3031
#include "parser/parse_type.h"
3132
#include "storage/ipc.h"
33+
#include "tcop/tcopprot.h"
3234
#include "utils/builtins.h"
3335
#include "utils/fmgroids.h"
3436
#include "utils/guc.h"
@@ -742,6 +744,18 @@ plperl_init_interp(void)
742744
char *dummy_env[1] = {NULL};
743745

744746
PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char ***) &dummy_env);
747+
748+
/*
749+
* For unclear reasons, PERL_SYS_INIT3 sets the SIGFPE handler to
750+
* SIG_IGN. Aside from being extremely unfriendly behavior for a
751+
* library, this is dumb on the grounds that the results of a
752+
* SIGFPE in this state are undefined according to POSIX, and in
753+
* fact you get a forced process kill at least on Linux. Hence,
754+
* restore the SIGFPE handler to the backend's standard setting.
755+
* (See Perl bug 114574 for more information.)
756+
*/
757+
pqsignal(SIGFPE, FloatExceptionHandler);
758+
745759
perl_sys_init_done = 1;
746760
/* quiet warning if PERL_SYS_INIT3 doesn't use the third argument */
747761
dummy_env[0] = NULL;

0 commit comments

Comments
 (0)