pl/perl extension fails on Windows
Hi,
I compiled PG 10 beta1/beta2 with "--with-perl" option on Windows and the
extension crashes the database.
--
postgres=# create extension plperl;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
postgres=#
It doesn't produce crashdump (in $DATA/crashdumps) but the log contains the
following error:
*src/pl/plperl/Util.c: loadable library and perl binaries are mismatched
(got handshake key 0A900080, needed 0AC80080)*
--
This is seen with Perl 5.24 but not with 5.20, 5.16. What I found is that
the handshake function is added in Perl 5.21.x and probably that is why we
don't see this issue in earlier versions.
The Perl that is used during compilation and on the target machine is same.
So probably plperl is not able to load the perl library. It works fine on
Linux and MacOS.
--
Sandeep Thakkar
EDB
Sandeep Thakkar <sandeep.thakkar@enterprisedb.com> writes:
I compiled PG 10 beta1/beta2 with "--with-perl" option on Windows and the
extension crashes the database.
*src/pl/plperl/Util.c: loadable library and perl binaries are mismatched
(got handshake key 0A900080, needed 0AC80080)*
This is seen with Perl 5.24 but not with 5.20, 5.16. What I found is that
the handshake function is added in Perl 5.21.x and probably that is why we
don't see this issue in earlier versions.
Well, we have various buildfarm machines running perls newer than that,
eg, crake, with 5.24.1. So I'd say there is something busted about your
perl installation. Perhaps leftover bits of an older version somewhere?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 12, 2017 at 4:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Sandeep Thakkar <sandeep.thakkar@enterprisedb.com> writes:
I compiled PG 10 beta1/beta2 with "--with-perl" option on Windows and the
extension crashes the database.
*src/pl/plperl/Util.c: loadable library and perl binaries are mismatched
(got handshake key 0A900080, needed 0AC80080)*This is seen with Perl 5.24 but not with 5.20, 5.16. What I found is that
the handshake function is added in Perl 5.21.x and probably that is whywe
don't see this issue in earlier versions.
Well, we have various buildfarm machines running perls newer than that,
eg, crake, with 5.24.1. So I'd say there is something busted about your
perl installation. Perhaps leftover bits of an older version somewhere?
Well crake is a Fedora box - and we have no problems on Linux, only on
Windows.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On 07/12/2017 11:49 AM, Dave Page wrote:
On Wed, Jul 12, 2017 at 4:35 PM, Tom Lane <tgl@sss.pgh.pa.us
<mailto:tgl@sss.pgh.pa.us>> wrote:Sandeep Thakkar <sandeep.thakkar@enterprisedb.com
<mailto:sandeep.thakkar@enterprisedb.com>> writes:I compiled PG 10 beta1/beta2 with "--with-perl" option on
Windows and the
extension crashes the database.
*src/pl/plperl/Util.c: loadable library and perl binaries aremismatched
(got handshake key 0A900080, needed 0AC80080)*
This is seen with Perl 5.24 but not with 5.20, 5.16. What I
found is that
the handshake function is added in Perl 5.21.x and probably that
is why we
don't see this issue in earlier versions.
Well, we have various buildfarm machines running perls newer than
that,
eg, crake, with 5.24.1. So I'd say there is something busted
about your
perl installation. Perhaps leftover bits of an older version
somewhere?Well crake is a Fedora box - and we have no problems on Linux, only on
Windows.
Yeah, I have this on one of my Windows boxes, and haven't had time to
get to the bottom of it yet ;-(
Latest versions of ActivePerl don't ship with library descriptor files,
either, which is unpleasant.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Jul 13, 2017 at 12:01 AM, Andrew Dunstan
<andrew.dunstan@2ndquadrant.com> wrote:
On 07/12/2017 11:49 AM, Dave Page wrote:
Well crake is a Fedora box - and we have no problems on Linux, only on
Windows.Yeah, I have this on one of my Windows boxes, and haven't had time to
get to the bottom of it yet ;-(
I could also see this problem in my Windows machine and I have spent
some time to analyse it. Here are my findings:
The stacktrace where the crash happens is:
perl524.dll!Perl_xs_handshake(const unsigned long key, void
*v_my_perl, const char * file, ...) Line 5569 C
plperl.dll!boot_PostgreSQL__InServer__Util(interpreter * my_perl, cv
* cv) Line 490 + 0x22 bytes C
perl524.dll!Perl_pp_entersub(interpreter * my_perl) Line 3987 + 0xc bytes C
perl524.dll!Perl_runops_standard(interpreter * my_perl) Line 41 + 0x6 bytes C
perl524.dll!S_run_body(interpreter * my_perl, long oldscope) Line 2485 C
perl524.dll!perl_run(interpreter * my_perl) Line 2406 + 0xc bytes C
plperl.dll!plperl_init_interp() Line 829 + 0xb bytes C
plperl.dll!_PG_init() Line 470 + 0x5 bytes C
I couldn't get much out of above bt, but, one thing i could notice is
that the input key passed to 'Perl_xs_handshake()' function is not
matching with the key being generated inside 'Perl_xs_handshake()',
hence, the handshaking is failing.
Please have a look into the following code snippet from 'perl 5.24'
and 'Util.c' file in plperl respectively,
Perl-5.24:
=======
got = INT2PTR(void*, (UV)(key & HSm_KEY_MATCH));
need = (void *)(HS_KEY(FALSE, FALSE, "", "") & HSm_KEY_MATCH);
if (UNLIKELY(got != need))
goto bad_handshake;
Util.c in plperl:
==========
485 XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
486 {
487 #if PERL_VERSION_LE(5, 21, 5)
488 dVAR; dXSARGS;
489 #else
490 dVAR; dXSBOOTARGSAPIVERCHK;
Actually the macro 'dXSBOOTARGSAPIVERCHK' in line #490 gets expanded to,
#define XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK
\
Perl_xs_handshake(HS_KEY(TRUE, TRUE, "v" PERL_API_VERSION_STRING,
""), \
HS_CXT, __FILE__, "v" PERL_API_VERSION_STRING)
And the point to be noted is, the way, the key is being generated in
above macro and in Perl_xs_handshake(). As shown above,
'XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK' macro passes
'PERL_API_VERSION_STRING' as input to HS_KEY() to generate the key and
this key is passed to Perl_xs_handshake function whereas inside
Perl_xs_handshake(), there is no such version string being used to
generate the key. Hence, the key mismatch is seen thereby resulting in
a bad_handshake error.
After doing some study, I could understand that Util.c is generated
from Util.xs by xsubpp compiler at build time. This is being done in
Mkvcbuild.pm file in postgres. If I manually replace
'dXSBOOTARGSAPIVERCHK' macro with 'dXSBOOTARGSNOVERCHK' macro in
src/pl/plperl/Util.c, the things work fine. The diff is as follows,
XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
- dVAR; dXSBOOTARGSAPIVERCHK;
+ dVAR; dXSBOOTARGSNOVERCHK;
I need to further investigate, but let me know if you have any ideas.
Latest versions of ActivePerl don't ship with library descriptor files,
either, which is unpleasant.
I too had similar observation and surprisingly, I am seeing
'libperl*.a' file instead of 'perl*.lib' file in most of the
ActiverPerl versions for Windows.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/13/2017 08:08 AM, Ashutosh Sharma wrote:
After doing some study, I could understand that Util.c is generated
from Util.xs by xsubpp compiler at build time. This is being done in
Mkvcbuild.pm file in postgres. If I manually replace
'dXSBOOTARGSAPIVERCHK' macro with 'dXSBOOTARGSNOVERCHK' macro in
src/pl/plperl/Util.c, the things work fine. The diff is as follows,XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
- dVAR; dXSBOOTARGSAPIVERCHK;
+ dVAR; dXSBOOTARGSNOVERCHK;I need to further investigate, but let me know if you have any ideas.
Good job hunting this down!
One suggestion I saw in a little googling was that we add this to the XS
file after the inclusion of XSUB.h:
#undef dXSBOOTARGSAPIVERCHK
#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHK
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
On 07/13/2017 08:08 AM, Ashutosh Sharma wrote:
- dVAR; dXSBOOTARGSAPIVERCHK; + dVAR; dXSBOOTARGSNOVERCHK;
Good job hunting this down!
One suggestion I saw in a little googling was that we add this to the XS
file after the inclusion of XSUB.h:
#undef dXSBOOTARGSAPIVERCHK
#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHK
I don't see anything even vaguely like that in the Util.c file generated
by Perl 5.10.1, which is what I've got on my RHEL machine.
What I do notice is this in Util.xs:
VERSIONCHECK: DISABLE
which leads immediately to two questions:
1. Why is your version of xsubpp apparently ignoring this directive
and generating a version check anyway?
2. Why do we have this directive in the first place? It does not seem
to me like a terribly great idea to ignore low-level version mismatches.
In the same vein, I'm suspicious of proposals to "fix" this problem
by removing the version check, which seems to be where Ashutosh
is headed. In the long run that seems certain to cause huge headaches.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/13/2017 10:36 AM, Tom Lane wrote:
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
On 07/13/2017 08:08 AM, Ashutosh Sharma wrote:
- dVAR; dXSBOOTARGSAPIVERCHK; + dVAR; dXSBOOTARGSNOVERCHK;Good job hunting this down!
One suggestion I saw in a little googling was that we add this to the XS
file after the inclusion of XSUB.h:
#undef dXSBOOTARGSAPIVERCHK
#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHKI don't see anything even vaguely like that in the Util.c file generated
by Perl 5.10.1, which is what I've got on my RHEL machine.
This is all fairly modern, so it's hardly surprising that it doesn't
happen with the ancient perl 5.10.
here's a snippet from the generated Util.c on crake (Fedora 25, perl 5.24):
XS_EXTERNAL(boot_PostgreSQL__InServer__Util); /* prototype to pass
-Wmissing-prototypes */
XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
dVAR; dXSBOOTARGSAPIVERCHK;
#endif
What I do notice is this in Util.xs:
VERSIONCHECK: DISABLE
which leads immediately to two questions:
1. Why is your version of xsubpp apparently ignoring this directive
and generating a version check anyway?2. Why do we have this directive in the first place? It does not seem
to me like a terribly great idea to ignore low-level version mismatches.In the same vein, I'm suspicious of proposals to "fix" this problem
by removing the version check, which seems to be where Ashutosh
is headed. In the long run that seems certain to cause huge headaches.
That is a different version check. It's the equivalent of xsubpp's
--noversioncheck flag. The versions it would check are the object file
and the corresponding pm file.
In fact the usage I suggested seems to be blessed in XSUB.h in this comment:
/* dXSBOOTARGSNOVERCHK has no API in xsubpp to choose it so do
#undef dXSBOOTARGSXSAPIVERCHK
#define dXSBOOTARGSXSAPIVERCHK dXSBOOTARGSNOVERCHK */
It would be nice to get to the bottom of why we're getting a version
mismatch on Windows, since we're clearly not getting one on Linux. But
since we've got on happily all these years without the API version check
we might well survive a few more going on as we are.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
It would be nice to get to the bottom of why we're getting a version
mismatch on Windows, since we're clearly not getting one on Linux.
Yeah, that's what's bothering me: as long as that remains unexplained,
I don't have any confidence that we're fixing the right thing.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Re: Dave Page 2017-07-12 <CA+OCxox=h5xftcnyk1AfA_QKSQSruD=Er0qweZakiCEg3U4rcg@mail.gmail.com>
Well, we have various buildfarm machines running perls newer than that,
eg, crake, with 5.24.1. So I'd say there is something busted about your
perl installation. Perhaps leftover bits of an older version somewhere?Well crake is a Fedora box - and we have no problems on Linux, only on
Windows.
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
/messages/by-id/20130515064201.GC704@msgid.df7cb.de
(Arguably, this is a toy architecture, so we can just leave it unfixed
there without any harm...)
Christoph
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Jul 13, 2017 at 6:04 PM, Andrew Dunstan
<andrew.dunstan@2ndquadrant.com> wrote:
On 07/13/2017 08:08 AM, Ashutosh Sharma wrote:
After doing some study, I could understand that Util.c is generated
from Util.xs by xsubpp compiler at build time. This is being done in
Mkvcbuild.pm file in postgres. If I manually replace
'dXSBOOTARGSAPIVERCHK' macro with 'dXSBOOTARGSNOVERCHK' macro in
src/pl/plperl/Util.c, the things work fine. The diff is as follows,XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
- dVAR; dXSBOOTARGSAPIVERCHK;
+ dVAR; dXSBOOTARGSNOVERCHK;I need to further investigate, but let me know if you have any ideas.
Good job hunting this down!
One suggestion I saw in a little googling was that we add this to the XS
file after the inclusion of XSUB.h:#undef dXSBOOTARGSAPIVERCHK
#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHK
Thanks for that suggestion. It was really helpful. I think, the point
is, in XSUB.h, the macro 'dXSBOOTARGSXSAPIVERCHK' has been redefined
for novercheck but surprisingly it hasn't been done for
'dXSBOOTARGSAPIVERCHK' macro and that could be the reason why we want
to redefine it in the XS file after including XSUB.h file. Attached is
the patch that redefines 'dXSBOOTARGSAPIVERCHK' in Util.xs and SPI.xs
files. Please have a look into the attached patch and let me know your
comments. Thanks.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Attachments:
redefine_dXSBOOTARGSAPIVERCHK_macro.patchapplication/octet-stream; name=redefine_dXSBOOTARGSAPIVERCHK_macro.patchDownload
diff --git a/src/pl/plperl/SPI.xs b/src/pl/plperl/SPI.xs
index 0447c50..1175426 100644
--- a/src/pl/plperl/SPI.xs
+++ b/src/pl/plperl/SPI.xs
@@ -18,6 +18,8 @@
#include "plperl.h"
#include "plperl_helpers.h"
+#undef dXSBOOTARGSAPIVERCHK
+#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHK
/*
* Interface routine to catch ereports and punt them to Perl
diff --git a/src/pl/plperl/Util.xs b/src/pl/plperl/Util.xs
index dbba0d7..d642aa5 100644
--- a/src/pl/plperl/Util.xs
+++ b/src/pl/plperl/Util.xs
@@ -23,6 +23,9 @@
#include "plperl.h"
#include "plperl_helpers.h"
+#undef dXSBOOTARGSAPIVERCHK
+#define dXSBOOTARGSAPIVERCHK dXSBOOTARGSNOVERCHK
+
/*
* Implementation of plperl's elog() function
*
On Thu, Jul 13, 2017 at 10:30 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
It would be nice to get to the bottom of why we're getting a version
mismatch on Windows, since we're clearly not getting one on Linux.Yeah, that's what's bothering me: as long as that remains unexplained,
I don't have any confidence that we're fixing the right thing.
Okay, I tried to explore on this a bit and my findings are as follows.
On Linux, the handshake key being generated in plperl code i.e. inside
XS_EXTERNAL() in Util.c (generated from Util.xs during build time) and perl
code (inside Perl_xs_handshake function) are same which means the following
condition inside Perl_xs_handshake() becomes true and therefore, there is
no mismatch error.
got = INT2PTR(void*, (UV)(key & HSm_KEY_MATCH));
need = (void *)(HS_KEY(FALSE, FALSE, "", "") & HSm_KEY_MATCH);
if (UNLIKELY(got != need))
goto bad_handshake;
However, on Windows, the handshake key generated in plperl code inside
XS_EXTERNAL() and in perl code i.e. inside Perl_xs_handshake() are
different thereby resulting in a mismatch error.
Actually the function used for generation of handshake Key i.e HS_KEYp()
considers 'sizeof(PerlInterpreter)' to generate the key and somehow the
sizeof PerlInterpreter is not uniform in plperl and perl modules incase of
Windows but on Linux it remains same in both the modules.
This is how PerlInterpreter is defined in Perl source,
*typedef struct interpreter PerlInterpreter;struct interpreter {# include
"intrpvar.h"};*
where intrpvar.h has different variables defined inside it and most of the
variables definition are protected with various macros. And there are some
macros that are just defined in perl but not in plperl module which means
the sizeof(PerlInterpreter) on the two modules are going to be different
and thereby resulting in a different key. But, then the point is, why no
such difference is observed on Linux. Well, as of now, i haven't found the
reason behind it and i am still investigating on it.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Show quoted text
regards, tom lane
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Actually the function used for generation of handshake Key i.e HS_KEYp()
considers 'sizeof(PerlInterpreter)' to generate the key and somehow the
sizeof PerlInterpreter is not uniform in plperl and perl modules incase of
Windows but on Linux it remains same in both the modules.
Yipes. So actually, this is catching a live ABI problem, which presumably
we've escaped seeing bad effects from only through sheer good luck.
I suppose that the discrepancies in the struct contents only occur after
the last field that plperl happens to touch directly --- but that is
unlikely to be true forever.
*typedef struct interpreter PerlInterpreter;struct interpreter {# include
"intrpvar.h"};*
where intrpvar.h has different variables defined inside it and most of the
variables definition are protected with various macros. And there are some
macros that are just defined in perl but not in plperl module which means
the sizeof(PerlInterpreter) on the two modules are going to be different
and thereby resulting in a different key.
I imagine the route to a solution is to fix things so that the relevant
macros are all defined correctly in both cases. But why they aren't
already is certainly an interesting question. Have you identified just
which fields are added or missing relative to what libperl thinks?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 19, 2017 at 12:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Actually the function used for generation of handshake Key i.e HS_KEYp()
considers 'sizeof(PerlInterpreter)' to generate the key and somehow the
sizeof PerlInterpreter is not uniform in plperl and perl modules incase of
Windows but on Linux it remains same in both the modules.Yipes.
+1 for "yipes". It sounds like we should really try to fix the
underlying problem, rather than just working around the check.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 19, 2017 at 9:42 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Actually the function used for generation of handshake Key i.e HS_KEYp()
considers 'sizeof(PerlInterpreter)' to generate the key and somehow the
sizeof PerlInterpreter is not uniform in plperl and perl modules incase of
Windows but on Linux it remains same in both the modules.Yipes. So actually, this is catching a live ABI problem, which presumably
we've escaped seeing bad effects from only through sheer good luck.
I suppose that the discrepancies in the struct contents only occur after
the last field that plperl happens to touch directly --- but that is
unlikely to be true forever.*typedef struct interpreter PerlInterpreter;struct interpreter {# include
"intrpvar.h"};*
where intrpvar.h has different variables defined inside it and most of the
variables definition are protected with various macros. And there are some
macros that are just defined in perl but not in plperl module which means
the sizeof(PerlInterpreter) on the two modules are going to be different
and thereby resulting in a different key.I imagine the route to a solution is to fix things so that the relevant
macros are all defined correctly in both cases. But why they aren't
already is certainly an interesting question. Have you identified just
which fields are added or missing relative to what libperl thinks?
Here are the list of macros and variables from 'intrpvar.h' file that
are just defined in perl module but not in plperl on Windows,
#ifdef PERL_USES_PL_PIDSTATUS
PERLVAR(I, pidstatus, HV *) /* pid-to-status mappings for waitpid */
#endif
#ifdef PERL_SAWAMPERSAND
PERLVAR(I, sawampersand, U8) /* must save all match strings */
#endif
#ifdef FCRYPT
PERLVARI(I, cryptseen, bool, FALSE) /* has fast crypt() been initialized? */
#else
/* One byte hole in the interpreter structure. */
#endif
#ifdef USE_REENTRANT_API
PERLVAR(I, reentrant_buffer, REENTR *) /* here we store the _r buffers */
#endif
#ifdef PERL_GLOBAL_STRUCT_PRIVATE
PERLVARI(I, my_cxt_keys, const char **, NULL) /* per-module array of
pointers to MY_CXT_KEY constants */
# endif
#ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
/* File descriptor to talk to the child which dumps scalars. */
PERLVARI(I, dumper_fd, int, -1)
#endif
#ifdef DEBUG_LEAKING_SCALARS
PERLVARI(I, sv_serial, U32, 0) /* SV serial number, used in sv.c */
#endif
#ifdef PERL_TRACE_OPS
PERLVARA(I, op_exec_cnt, OP_max+2, UV)
#endif
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
On Wed, Jul 19, 2017 at 9:42 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
I imagine the route to a solution is to fix things so that the relevant
macros are all defined correctly in both cases. But why they aren't
already is certainly an interesting question. Have you identified just
which fields are added or missing relative to what libperl thinks?
Here are the list of macros and variables from 'intrpvar.h' file that
are just defined in perl module but not in plperl on Windows,
#ifdef PERL_USES_PL_PIDSTATUS
PERLVAR(I, pidstatus, HV *) /* pid-to-status mappings for waitpid */
#endif
#ifdef PERL_SAWAMPERSAND
PERLVAR(I, sawampersand, U8) /* must save all match strings */
#endif
#ifdef FCRYPT
PERLVARI(I, cryptseen, bool, FALSE) /* has fast crypt() been initialized? */
#else
/* One byte hole in the interpreter structure. */
#endif
#ifdef USE_REENTRANT_API
PERLVAR(I, reentrant_buffer, REENTR *) /* here we store the _r buffers */
#endif
#ifdef PERL_GLOBAL_STRUCT_PRIVATE
PERLVARI(I, my_cxt_keys, const char **, NULL) /* per-module array of
pointers to MY_CXT_KEY constants */
# endif
#ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
/* File descriptor to talk to the child which dumps scalars. */
PERLVARI(I, dumper_fd, int, -1)
#endif
#ifdef DEBUG_LEAKING_SCALARS
PERLVARI(I, sv_serial, U32, 0) /* SV serial number, used in sv.c */
#endif
#ifdef PERL_TRACE_OPS
PERLVARA(I, op_exec_cnt, OP_max+2, UV)
#endif
Huh. So those seem like symbols that ought to be exposed somewhere in
Perl's headers. Perhaps we're failing to #include some "perl_config.h" or
equivalent file that records these ABI options?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Here are the list of macros and variables from 'intrpvar.h' file that
are just defined in perl module but not in plperl on Windows,
#ifdef PERL_USES_PL_PIDSTATUS
PERLVAR(I, pidstatus, HV *) /* pid-to-status mappings for waitpid */
#endif
#ifdef PERL_SAWAMPERSAND
PERLVAR(I, sawampersand, U8) /* must save all match strings */
#endif
I am really suspicious that this means your libperl was built in an unsafe
fashion, that is, by injecting configuration choices as random -D switches
in the build process rather than making sure the choices were recorded in
perl's config.h. As an example, looking at the perl 5.24.1 headers on
a Fedora box, it looks to me like PERL_SAWAMPERSAND could only get defined
if PERL_COPY_ON_WRITE were not defined, and the only way that that can
happen is if PERL_NO_COW is defined, and there are no references to the
latter anyplace except in this particular #if defined test in perl.h.
Where did your perl installation come from, anyway? Are you sure the .h
files match up with the executables?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 19, 2017 at 05:01:31PM -0400, Tom Lane wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Here are the list of macros and variables from 'intrpvar.h' file that
are just defined in perl module but not in plperl on Windows,#ifdef PERL_USES_PL_PIDSTATUS
PERLVAR(I, pidstatus, HV *) /* pid-to-status mappings for waitpid */
#endif#ifdef PERL_SAWAMPERSAND
PERLVAR(I, sawampersand, U8) /* must save all match strings */
#endifI am really suspicious that this means your libperl was built in an unsafe
fashion, that is, by injecting configuration choices as random -D switches
in the build process rather than making sure the choices were recorded in
perl's config.h. As an example, looking at the perl 5.24.1 headers on
a Fedora box, it looks to me like PERL_SAWAMPERSAND could only get defined
if PERL_COPY_ON_WRITE were not defined, and the only way that that can
happen is if PERL_NO_COW is defined, and there are no references to the
latter anyplace except in this particular #if defined test in perl.h.Where did your perl installation come from, anyway? Are you sure the .h
files match up with the executables?
I see corresponding symptoms with the following Perl distributions:
strawberry-perl-5.26.0.1-64bit.msi:
src/pl/plperl/Util.c: loadable library and perl binaries are mismatched (got handshake key 0000000011800080, needed 0000000011c00080)
ActivePerl-5.24.1.2402-MSWin32-x64-401627.exe:
src/pl/plperl/Util.c: loadable library and perl binaries are mismatched (got handshake key 0000000011500080, needed 0000000011900080)
So, this affects each of the two prominent families of Perl Windows binaries.
Notes for anyone trying to reproduce:
- Both of those Perl distributions require the hacks described here:
/messages/by-id/CABcP5fjEjgOsh097cWnQrsK9yCswo4DZxp-V47DKCH-MxY9Gig@mail.gmail.com
- Add PERL_USE_UNSAFE_INC=1 to the environment until we update things to cope
with this Perl 5.26 change:
http://search.cpan.org/~xsawyerx/perl-5.26.0/pod/perldelta.pod#Removal_of_the_current_directory_(%22.%22)_from_@INC
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Mon, Jul 24, 2017 at 11:58 AM, Noah Misch <noah@leadboat.com> wrote:
On Wed, Jul 19, 2017 at 05:01:31PM -0400, Tom Lane wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Here are the list of macros and variables from 'intrpvar.h' file that
are just defined in perl module but not in plperl on Windows,#ifdef PERL_USES_PL_PIDSTATUS
PERLVAR(I, pidstatus, HV *) /* pid-to-status mappings for waitpid */
#endif#ifdef PERL_SAWAMPERSAND
PERLVAR(I, sawampersand, U8) /* must save all match strings */
#endifI am really suspicious that this means your libperl was built in an unsafe
fashion, that is, by injecting configuration choices as random -D switches
in the build process rather than making sure the choices were recorded in
perl's config.h. As an example, looking at the perl 5.24.1 headers on
a Fedora box, it looks to me like PERL_SAWAMPERSAND could only get defined
if PERL_COPY_ON_WRITE were not defined, and the only way that that can
happen is if PERL_NO_COW is defined, and there are no references to the
latter anyplace except in this particular #if defined test in perl.h.Where did your perl installation come from, anyway? Are you sure the .h
files match up with the executables?I see corresponding symptoms with the following Perl distributions:
strawberry-perl-5.26.0.1-64bit.msi:
src/pl/plperl/Util.c: loadable library and perl binaries are mismatched (got handshake key 0000000011800080, needed 0000000011c00080)
ActivePerl-5.24.1.2402-MSWin32-x64-401627.exe:
src/pl/plperl/Util.c: loadable library and perl binaries are mismatched (got handshake key 0000000011500080, needed 0000000011900080)So, this affects each of the two prominent families of Perl Windows binaries.
I think the real question is where do we go from here. Ashutosh has
proposed a patch up-thread based on a suggestion from Andrew, but it
is not clear if we want to go there as that seems to be bypassing
handshake mechanism. The other tests and analysis seem to indicate
that the new version Perl binaries on Windows are getting built with
flags that are incompatible with what we use for plperl and it is not
clear why perl is using those flags. Do you think we can do something
at our end to make it work or someone should check with Perl community
about it?
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 19, 2017 at 5:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
I am really suspicious that this means your libperl was built in an unsafe
fashion, that is, by injecting configuration choices as random -D switches
in the build process rather than making sure the choices were recorded in
perl's config.h. As an example, looking at the perl 5.24.1 headers on
a Fedora box, it looks to me like PERL_SAWAMPERSAND could only get defined
if PERL_COPY_ON_WRITE were not defined, and the only way that that can
happen is if PERL_NO_COW is defined, and there are no references to the
latter anyplace except in this particular #if defined test in perl.h.
Hmm, it might not be so random as all that. Have a look at this
commit log entry:
commit 1a904fc88069e249a4bd0ef196a3f1a7f549e0fe
Author: Father Chrysostomos <sprout@cpan.org>
Date: Sun Nov 25 12:57:04 2012 -0800
Disable PL_sawampersand
PL_sawampersand actually causes bugs (e.g., perl #4289), because the
behaviour changes. eval '$&' after a match will produce different
results depending on whether $& was seen before the match.
Using copy-on-write for the pre-match copy (preceding patches do that)
alleviates the slowdown caused by mentioning $&. The copy doesn’t
happen unless the string is modified after the match. It’s now a
post- match copy. So we no longer need to do things differently
depending on whether $& has been seen.
PL_sawampersand is now #defined to be equal to what it would be if
every program began with $',$&,$`.
I left the PL_sawampersand code in place, in case this commit proves
immature. Running Configure with -Accflags=PERL_SAWAMPERSAND will
reënable the PL_sawampersand mechanism.
Based on a bit of experimentation, that last bit contains a typo: it
should say -Accflags=-DPERL_SAWAMPERSAND; as written, the -D is
missing.[1]Arguably, the umlaut over "reenable" is also a typo, but that's a sort of in a different category. Anyway, the point is that at least in this case, there
seems to have been some idea that somebody might want to reenable this
in their own build even after it was disabled by default.
Perl also has a mechanism for flags added to Configure to be passed
along when building loadable modules; if it didn't, not just plperl
but every Perl module written in C would have this issue if any such
flags where used. Normally, you compile perl modules by running "perl
Makefile.PL" to generate a makefile, and then building from the
makefile. If you do that, then the Makefile ends up with a section in
it that looks like this:
# --- MakeMaker cflags section:
CCFLAGS = -fno-strict-aliasing -pipe -fstack-protector-strong
-I/opt/local/include -DPERL_USE_SAFE_PUTENV -DPERL_SAWAMPERSAND -Wall
-Werror=declaration-after-statement -Wextra -Wc++-compat
-Wwrite-strings
OPTIMIZE = -O3
PERLTYPE =
MPOLLUTE =
...and lo-and-behold, the -DPERL_SAWAMPERSAND flag which I passed to
Configure is there. After a bit of time deciphering how MakeMaker
actually works, I figured out that it gets the value for CFLAGS by
doing "use Config;" and then referencing $Config::Config{'ccflags'};
an alternative way to get it, from the shell, is to run perl
-V:ccflags.
While I'm not sure of the details, I suspect that we need to use one
of those methods to get the CCFLAGS used to build perl, and include
those when SPI.o, Util.o, and plperl.o in src/pl/plperl. Or at least
the -D switches from those CCFLAGS. Here's about the simplest thing
that seems like it might work on Linux; Windows would need something
equivalent:
override CPPFLAGS += $(shell $(PERL) -MConfig -e 'print
$$Config::Config{"ccflags"};')
On my MacBook Pro, with the built-in switches, that produces:
-fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os
-fno-strict-aliasing -fstack-protector-strong -I/opt/local/include
-DPERL_USE_SAFE_PUTENV
Or we could try to extract just the -D switches:
override CPPFLAGS += $(shell $(PERL) -MConfig -e 'print join " ", grep
{ /^-D/ } split /\s+/, $$Config::Config{"ccflags"};')
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
[1]: Arguably, the umlaut over "reenable" is also a typo, but that's a sort of in a different category.
sort of in a different category.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/25/2017 08:58 AM, Amit Kapila wrote:
I think the real question is where do we go from here. Ashutosh has
proposed a patch up-thread based on a suggestion from Andrew, but it
is not clear if we want to go there as that seems to be bypassing
handshake mechanism. The other tests and analysis seem to indicate
that the new version Perl binaries on Windows are getting built with
flags that are incompatible with what we use for plperl and it is not
clear why perl is using those flags. Do you think we can do something
at our end to make it work or someone should check with Perl community
about it?
No amount of checking with the Perl community is likely to resolve this
quickly w.r.t. existing releases of Perl.
We seem to have a choice either to abandon, at least temporarily, perl
support on Windows for versions of perl >= 5.20 (I think) or adopt the
suggestion I made. It's not a complete hack - it's something at least
somewhat blessed in perl's XSUB.h:
/* dXSBOOTARGSNOVERCHK has no API in xsubpp to choose it so do
#undef dXSBOOTARGSXSAPIVERCHK
#define dXSBOOTARGSXSAPIVERCHK dXSBOOTARGSNOVERCHK */
Note that on earlier versions of perl we got by without this check for
years without any issue or complaint I recall hearing of. If we don't
adopt this I would not be at all surprised to see Windows packagers
adopt it anyway.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Amit Kapila <amit.kapila16@gmail.com> writes:
I think the real question is where do we go from here. Ashutosh has
proposed a patch up-thread based on a suggestion from Andrew, but it
is not clear if we want to go there as that seems to be bypassing
handshake mechanism.
That definitely seems like the wrong route to me. If the resulting
code works, it would at best be accidental.
The other tests and analysis seem to indicate
that the new version Perl binaries on Windows are getting built with
flags that are incompatible with what we use for plperl and it is not
clear why perl is using those flags. Do you think we can do something
at our end to make it work or someone should check with Perl community
about it?
It would be a good idea to find somebody who knows more about how these
Perl distros are built.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
No amount of checking with the Perl community is likely to resolve this
quickly w.r.t. existing releases of Perl.
Yes, but if they are shipping broken perl builds that cannot support
building of extension modules, they need to be made aware of that.
If that *isn't* the explanation, then we need to find out what is.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
Perl also has a mechanism for flags added to Configure to be passed
along when building loadable modules; if it didn't, not just plperl
but every Perl module written in C would have this issue if any such
flags where used.
...
While I'm not sure of the details, I suspect that we need to use one
of those methods to get the CCFLAGS used to build perl, and include
those when SPI.o, Util.o, and plperl.o in src/pl/plperl. Or at least
the -D switches from those CCFLAGS.
Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.
It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/25/2017 11:00 AM, Tom Lane wrote:
Robert Haas <robertmhaas@gmail.com> writes:
Perl also has a mechanism for flags added to Configure to be passed
along when building loadable modules; if it didn't, not just plperl
but every Perl module written in C would have this issue if any such
flags where used.
...
While I'm not sure of the details, I suspect that we need to use one
of those methods to get the CCFLAGS used to build perl, and include
those when SPI.o, Util.o, and plperl.o in src/pl/plperl. Or at least
the -D switches from those CCFLAGS.Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).
-s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv
-fno-strict-aliasing -mms-bitfields -I"C:\Perl64\lib\CORE"
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Jul 25, 2017 at 11:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).
Why ccopts rather than ccflags?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
On Tue, Jul 25, 2017 at 11:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).
Why ccopts rather than ccflags?
I was looking at the current code which fetches ldopts, and analogizing.
Don't know the difference between ccflags and ccopts.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Jul 25, 2017 at 11:32 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Robert Haas <robertmhaas@gmail.com> writes:
On Tue, Jul 25, 2017 at 11:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).Why ccopts rather than ccflags?
I was looking at the current code which fetches ldopts, and analogizing.
Don't know the difference between ccflags and ccopts.
Oh, here I was thinking you were 3 steps ahead of me. :-)
Per "perldoc ExtUtils::Embed", ccopts() = perl_inc() plus ccflags()
plus ccdlflags().
On my system:
[rhaas pgsql]$ perl -MExtUtils::Embed -e 'for (qw(ccopts ccflags
ccdlflags perl_inc)) { print "==$_==\n"; eval "$_()"; print "\n\n";
};'
==ccopts==
-fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os
-fno-strict-aliasing -fstack-protector-strong -I/opt/local/include
-DPERL_USE_SAFE_PUTENV
-I/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/CORE
==ccflags==
-fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os
-fno-strict-aliasing -fstack-protector-strong -I/opt/local/include
-DPERL_USE_SAFE_PUTENV
==ccdlflags==
==perl_inc==
-I/opt/local/lib/perl5/5.24/darwin-thread-multi-2level/CORE
I don't have a clear sense of whether ccopts() or ccflags() is what we
want here, but FWIW ccopts() is more inclusive.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/25/2017 11:32 AM, Tom Lane wrote:
Robert Haas <robertmhaas@gmail.com> writes:
On Tue, Jul 25, 2017 at 11:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hm, I had the idea that we were already asking ExtUtils::Embed for that,
but now I see we only inquire about LDFLAGS not CCFLAGS. Yes, this sounds
like a promising avenue to pursue.It would be useful to see the results of
perl -MExtUtils::Embed -e ccopts
on one of the affected installations, and compare that to the problematic
field(s).Why ccopts rather than ccflags?
I was looking at the current code which fetches ldopts, and analogizing.
Don't know the difference between ccflags and ccopts.
per docs:
ccopts()
This function combines "perl_inc()", "ccflags()" and
"ccdlflags()"
into one.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Jul 25, 2017 at 10:23 AM, Robert Haas <robertmhaas@gmail.com> wrote:
While I'm not sure of the details, I suspect that we need to use one
of those methods to get the CCFLAGS used to build perl, and include
those when SPI.o, Util.o, and plperl.o in src/pl/plperl. Or at least
the -D switches from those CCFLAGS. Here's about the simplest thing
that seems like it might work on Linux; Windows would need something
equivalent:override CPPFLAGS += $(shell $(PERL) -MConfig -e 'print
$$Config::Config{"ccflags"};')On my MacBook Pro, with the built-in switches, that produces:
-fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os
-fno-strict-aliasing -fstack-protector-strong -I/opt/local/include
-DPERL_USE_SAFE_PUTENVOr we could try to extract just the -D switches:
override CPPFLAGS += $(shell $(PERL) -MConfig -e 'print join " ", grep
{ /^-D/ } split /\s+/, $$Config::Config{"ccflags"};')
Based on discussion downthread, it seems like what we actually need to
do is update perl.m4 to extract CCFLAGS. Turns out somebody proposed
a patch for that back in 2002:
/messages/by-id/Pine.LNX.4.44.0211051045070.16317-200000@wotan.suse.de
It seems to need a rebase. :-)
And maybe some other changes, too. I haven't carefully reviewed that thread.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
Based on discussion downthread, it seems like what we actually need to
do is update perl.m4 to extract CCFLAGS. Turns out somebody proposed
a patch for that back in 2002:
/messages/by-id/Pine.LNX.4.44.0211051045070.16317-200000@wotan.suse.de
It seems to need a rebase. :-)
Ah-hah, I *thought* we had considered the question once upon a time.
There were some pretty substantial compatibility concerns raised in that
thread, which is doubtless why it's still like that.
My beef about inter-compiler compatibility (if building PG with a
different compiler from that used for Perl) could probably be addressed by
absorbing only -D switches from the Perl flags. But Peter seemed to feel
that even that could break things, and I worry that he's right for cases
like -D_FILE_OFFSET_BITS which affect libc APIs. Usually we'd have made
the same decisions as Perl for that sort of thing, but if we didn't, it's
a mess.
I wonder whether we could adopt some rule like "absorb -D switches
for macros whose names do not begin with an underscore". That's
surely a hack and three-quarters, but it seems safer than just
absorbing everything willy-nilly.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jul 26, 2017 at 8:51 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Robert Haas <robertmhaas@gmail.com> writes:
Based on discussion downthread, it seems like what we actually need to
do is update perl.m4 to extract CCFLAGS. Turns out somebody proposed
a patch for that back in 2002:
/messages/by-id/Pine.LNX.4.44.0211051045070.16317-200000@wotan.suse.de
It seems to need a rebase. :-)Ah-hah, I *thought* we had considered the question once upon a time.
There were some pretty substantial compatibility concerns raised in that
thread, which is doubtless why it's still like that.My beef about inter-compiler compatibility (if building PG with a
different compiler from that used for Perl) could probably be addressed by
absorbing only -D switches from the Perl flags. But Peter seemed to feel
that even that could break things, and I worry that he's right for cases
like -D_FILE_OFFSET_BITS which affect libc APIs. Usually we'd have made
the same decisions as Perl for that sort of thing, but if we didn't, it's
a mess.I wonder whether we could adopt some rule like "absorb -D switches
for macros whose names do not begin with an underscore". That's
surely a hack and three-quarters, but it seems safer than just
absorbing everything willy-nilly.
Thanks Robert, Tom, Andrew and Amit for all your inputs. I have tried
to work on the patch shared by Reinhard long time back for Linux. I
had to rebase the patch and also had to do add some more lines of code
to make it work on Linux. For Windows, I had to prepare a separate
patch to replicate similar behaviour. I can see that both these
patches are working as expected i.e they are able import the switches
used by Perl into plperl module during build time. However, on
windows i am still seeing the crash and i am still working to find the
reason for this. Here, I attach the patches that i have prepared for
linux and Windows platforms. Thanks.
Attachments:
plperl_linux.patchapplication/octet-stream; name=plperl_linux.patchDownload
diff --git a/config/perl.m4 b/config/perl.m4
index bed2eae..d2ac2ef 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -49,6 +49,16 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
[m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
+# PGAC_CHECK_PERL_EMBED_CCFLAGS
+# -----------------------------
+AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
+[AC_REQUIRE([PGAC_PATH_PERL])
+AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/) {print $f, " "}}'`
+AC_SUBST(perl_ccflags)dnl
+AC_MSG_RESULT([$perl_ccflags])])
+
+
# PGAC_CHECK_PERL_EMBED_LDFLAGS
# -----------------------------
# We are after Embed's ldopts, but without the subset mentioned in
diff --git a/configure b/configure
index aff72eb..1e6bf86 100755
--- a/configure
+++ b/configure
@@ -667,6 +667,7 @@ python_includespec
python_version
python_majorversion
PYTHON
+perl_ccflags
perl_embed_ldflags
perl_useshrplib
perl_privlibexp
@@ -7767,6 +7768,19 @@ documentation for details. Use --without-perl to disable building
PL/Perl." "$LINENO" 5
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ccflags for embedded Perl" >&5
+$as_echo_n "checking for ccflags for embedded Perl... " >&6; }
+
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/) {print $f, " "}}'`
+
+if test -z "$perl_ccflags" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $perl_ccflags" >&5
+$as_echo "$perl_ccflags" >&6; }
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
if test "$PORTNAME" = "win32" ; then
diff --git a/configure.in b/configure.in
index 72e5b17..13c69d6 100644
--- a/configure.in
+++ b/configure.in
@@ -938,6 +938,7 @@ You might have to rebuild your Perl installation. Refer to the
documentation for details. Use --without-perl to disable building
PL/Perl.])
fi
+ PGAC_CHECK_PERL_EMBED_CCFLAGS
PGAC_CHECK_PERL_EMBED_LDFLAGS
fi
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index dc8a89a..ff1c185 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -304,6 +304,7 @@ else
endif
perl_archlibexp = @perl_archlibexp@
perl_privlibexp = @perl_privlibexp@
+perl_ccflags = @perl_ccflags@
perl_embed_ldflags = @perl_embed_ldflags@
# Miscellaneous
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index b8e3585..dce0513 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -12,7 +12,7 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
override CPPFLAGS += -Wno-comment
endif
-override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE
+override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE $(perl_ccflags)
rpathdir = $(perl_archlibexp)/CORE
plperl_win.patchapplication/octet-stream; name=plperl_win.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index e0bf607..0f50fde 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -518,6 +518,15 @@ sub mkvcbuild
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ foreach my $f (split(" ",$Config{ccflags}))
+ {
+ if ($f =~ /^-D/)
+ {
+ $plperl->AddDefine($f);
+ }
+ }
+
foreach my $xs ('SPI.xs', 'Util.xs')
{
(my $xsc = $xs) =~ s/\.xs/.c/;
Hi All,
On Wed, Jul 26, 2017 at 7:56 PM, Ashutosh Sharma <ashu.coek88@gmail.com> wrote:
On Wed, Jul 26, 2017 at 8:51 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Robert Haas <robertmhaas@gmail.com> writes:
Based on discussion downthread, it seems like what we actually need to
do is update perl.m4 to extract CCFLAGS. Turns out somebody proposed
a patch for that back in 2002:
/messages/by-id/Pine.LNX.4.44.0211051045070.16317-200000@wotan.suse.de
It seems to need a rebase. :-)Ah-hah, I *thought* we had considered the question once upon a time.
There were some pretty substantial compatibility concerns raised in that
thread, which is doubtless why it's still like that.My beef about inter-compiler compatibility (if building PG with a
different compiler from that used for Perl) could probably be addressed by
absorbing only -D switches from the Perl flags. But Peter seemed to feel
that even that could break things, and I worry that he's right for cases
like -D_FILE_OFFSET_BITS which affect libc APIs. Usually we'd have made
the same decisions as Perl for that sort of thing, but if we didn't, it's
a mess.I wonder whether we could adopt some rule like "absorb -D switches
for macros whose names do not begin with an underscore". That's
surely a hack and three-quarters, but it seems safer than just
absorbing everything willy-nilly.Thanks Robert, Tom, Andrew and Amit for all your inputs. I have tried
to work on the patch shared by Reinhard long time back for Linux. I
had to rebase the patch and also had to do add some more lines of code
to make it work on Linux. For Windows, I had to prepare a separate
patch to replicate similar behaviour. I can see that both these
patches are working as expected i.e they are able import the switches
used by Perl into plperl module during build time. However, on
windows i am still seeing the crash and i am still working to find the
reason for this. Here, I attach the patches that i have prepared for
linux and Windows platforms. Thanks.
There was a small problem with my patch for windows that i had
submitted yesterday. It was reading the switches in '-D*' form and
including those as it is in the plperl build. Infact, it should be
removing '-D' option (from say -DPERL_CORE) and just add the macro
name (PERL_CORE) to the define list using AddDefine('PERL_CORE').
Anyways, attached is the patch that corrects this issue. The patch now
imports all the switches used by perl into plperl module but, after
doing so, i am seeing some compilation errors on Windows. Following is
the error observed,
SPI.obj : error LNK2019: unresolved external symbol PerlProc_setjmp
referenced in function do_plperl_return_next
I did some analysis in order to find the reason for this error and
could see that for Windows, sigsetjmp is defined as setjmp in PG. But,
setjmp is also defined by Perl. Hence, after including perl header
files, setjmp gets redefined as 'PerlProc_setjmp'.
In short, we have 'src/pl/plperl/SPI.c' file including 'perl.h'
followed 'XSUB.h'. perl.h defines PerlProc_setjmp() as,
#define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
and Sigsetjmp is defined as:
#define Sigsetjmp(buf,save_mask) setjmp((buf))
Then XSUB.h redefines setjmp as:
# define setjmp PerlProc_setjmp
which basically creates a loop in the preprocessor definitions.
Another problem with setjmp() redefinition is that setjmp takes one
argument whereas PerlProc_setjmp takes two arguments.
To fix this compilation error i have removed the setjmp() redefinition
from XSUB.h in perl and after doing that the build succeeds and also
'create language plperl' command is working fine i.e. there is no more
server crash.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Attachments:
plperl_win_v2.patchapplication/octet-stream; name=plperl_win_v2.patchDownload
From 518bdc92b619b4d1c906431854e9728ddc955474 Mon Sep 17 00:00:00 2001
From: Ashutosh <ashu.coek@gmail.com>
Date: Thu, 27 Jul 2017 18:24:19 +0530
Subject: [PATCH] Windows fix
---
src/tools/msvc/Mkvcbuild.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index e0bf607..f1a991b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -518,6 +518,16 @@ sub mkvcbuild
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ foreach my $f (split(" ",$Config{ccflags}))
+ {
+ if ($f =~ /^-D/)
+ {
+ $f =~ s/\-D//;
+ $plperl->AddDefine($f);
+ }
+ }
+
foreach my $xs ('SPI.xs', 'Util.xs')
{
(my $xsc = $xs) =~ s/\.xs/.c/;
--
2.10.2.windows.1
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Anyways, attached is the patch that corrects this issue. The patch now
imports all the switches used by perl into plperl module but, after
doing so, i am seeing some compilation errors on Windows. Following is
the error observed,
SPI.obj : error LNK2019: unresolved external symbol PerlProc_setjmp
referenced in function do_plperl_return_next
That's certainly a mess, but how come that wasn't happening before?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Jul 27, 2017 at 7:51 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Anyways, attached is the patch that corrects this issue. The patch now
imports all the switches used by perl into plperl module but, after
doing so, i am seeing some compilation errors on Windows. Following is
the error observed,SPI.obj : error LNK2019: unresolved external symbol PerlProc_setjmp
referenced in function do_plperl_return_nextThat's certainly a mess, but how come that wasn't happening before?
Earlier we were using Perl-5.20 version which i think didn't have
handshaking mechanism. From perl-5.22 onwards, the functions like
Perl_xs_handshake() or HS_KEY were introduced for handshaking purpose and
to ensure that the handshaking between plperl and perl doesn't fail, we are
now trying to import the switches used by perl into plperl. As a result of
this, macros like PERL_IMPLICIT_SYS is getting defined in plperl which
eventually opens the following definitions from XSUB.h resulting in the
compilation error.
499 #if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE)
518 # undef ioctl
519 # undef getlogin
520* # undef setjmp*
...........
...........
651 # define times PerlProc_times
652 # define wait PerlProc_wait
653
*# define setjmp PerlProc_setjmp*
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Show quoted text
regards, tom lane
On 07/27/2017 12:34 PM, Ashutosh Sharma wrote:
On Thu, Jul 27, 2017 at 7:51 PM, Tom Lane <tgl@sss.pgh.pa.us
<mailto:tgl@sss.pgh.pa.us>> wrote:Ashutosh Sharma <ashu.coek88@gmail.com
<mailto:ashu.coek88@gmail.com>> writes:
Anyways, attached is the patch that corrects this issue. The patch now
imports all the switches used by perl into plperl module but, after
doing so, i am seeing some compilation errors on Windows. Following is
the error observed,SPI.obj : error LNK2019: unresolved external symbol PerlProc_setjmp
referenced in function do_plperl_return_nextThat's certainly a mess, but how come that wasn't happening before?
Earlier we were using Perl-5.20 version which i think didn't have
handshaking mechanism. From perl-5.22 onwards, the functions like
Perl_xs_handshake() or HS_KEY were introduced for handshaking purpose
and to ensure that the handshaking between plperl and perl doesn't
fail, we are now trying to import the switches used by perl into
plperl. As a result of this, macros like PERL_IMPLICIT_SYS is getting
defined in plperl which eventually opens the following definitions
from XSUB.h resulting in the compilation error.499 #if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE)
518 # undef ioctl
519 # undef getlogin
520*# undef setjmp*
...........
...........651 # define times PerlProc_times
652 # define wait PerlProc_wait
653 *# define setjmp PerlProc_setjmp*
What is the minimal set of extra defines required to sort out the
handshake fingerprint issue?
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
What is the minimal set of extra defines required to sort out the
handshake fingerprint issue?
Also, exactly what defines do you end up importing in your test build?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Jul 27, 2017 at 10:21 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Anyways, attached is the patch that corrects this issue. The patch now
imports all the switches used by perl into plperl module but, after
doing so, i am seeing some compilation errors on Windows. Following is
the error observed,SPI.obj : error LNK2019: unresolved external symbol PerlProc_setjmp
referenced in function do_plperl_return_nextThat's certainly a mess, but how come that wasn't happening before?
How about we fix it like this?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
pg-sigsetjmp.patchapplication/octet-stream; name=pg-sigsetjmp.patchDownload
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 00b1e823af..9facfd4ee3 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -506,7 +506,7 @@ AutoVacLauncherMain(int argc, char *argv[])
*
* This code is a stripped down version of PostgresMain error recovery.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -1576,7 +1576,7 @@ AutoVacWorkerMain(int argc, char *argv[])
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Prevents interrupts while cleaning up */
HOLD_INTERRUPTS();
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 28af6f0f07..8238d721f3 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -767,7 +767,7 @@ StartBackgroundWorker(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index 9ad74ee977..8b1596c658 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -171,7 +171,7 @@ BackgroundWriterMain(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -268,7 +268,7 @@ BackgroundWriterMain(void)
{
/*
* From here on, elog(ERROR) should end with exit(1), not send
- * control back to the sigsetjmp block above
+ * control back to the pg_sigsetjmp block above
*/
ExitOnAnyError = true;
/* Normal exit from the bgwriter is here */
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index e48ebd557f..682446e764 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -253,7 +253,7 @@ CheckpointerMain(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -392,7 +392,7 @@ CheckpointerMain(void)
{
/*
* From here on, elog(ERROR) should end with exit(1), not send
- * control back to the sigsetjmp block above
+ * control back to the pg_sigsetjmp block above
*/
ExitOnAnyError = true;
/* Close down the database */
diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
index 7b89e02428..4394b1e260 100644
--- a/src/backend/postmaster/walwriter.c
+++ b/src/backend/postmaster/walwriter.c
@@ -151,7 +151,7 @@ WalWriterMain(void)
*
* This code is heavily based on bgwriter.c, q.v.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index b8d860ebdb..67a72769fb 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3822,15 +3822,15 @@ PostgresMain(int argc, char *argv[],
* during error recovery. (If we get into an infinite loop thereby, it
* will soon be stopped by overflow of elog.c's internal state stack.)
*
- * Note that we use sigsetjmp(..., 1), so that this function's signal mask
- * (to wit, UnBlockSig) will be restored when longjmp'ing to here. This
- * is essential in case we longjmp'd out of a signal handler on a platform
- * where that leaves the signal blocked. It's not redundant with the
- * unblock in AbortTransaction() because the latter is only called if we
- * were inside a transaction.
+ * Note that we use pg_sigsetjmp(..., 1), so that this function's signal
+ * mask (to wit, UnBlockSig) will be restored when longjmp'ing to here.
+ * This is essential in case we longjmp'd out of a signal handler on a
+ * platform where that leaves the signal blocked. It's not redundant with
+ * the unblock in AbortTransaction() because the latter is only called if
+ * we were inside a transaction.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/*
* NOTE: if you are tempted to add more code in this if-block,
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index f01b814c6e..93caeb3c48 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -704,7 +704,7 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
int errorcount;
int token;
- if (sigsetjmp(flex_fatal_jmp, 1) == 0)
+ if (pg_sigsetjmp(flex_fatal_jmp, 1) == 0)
GUC_flex_fatal_jmp = &flex_fatal_jmp;
else
{
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 4e04459d45..b9f5946e25 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4423,7 +4423,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
* through the loop since it's conceivable something inside
* PSQLexecWatch could change sigint_interrupt_jmp.
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
break;
/*
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 724ea9211a..ab27c4b5ab 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -521,7 +521,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
* Establish longjmp destination for exiting from wait-for-input. (This is
* only effective while sigint_interrupt_enabled is TRUE.)
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
{
/* got here with longjmp */
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 0162ee8d2f..d2ebaaabda 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -108,7 +108,7 @@ MainLoop(FILE *source)
* must re-do this each time through the loop for safety, since the
* jmpbuf might get changed during command execution.
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
{
/* got here with longjmp */
diff --git a/src/include/c.h b/src/include/c.h
index 9066e3c578..6a934c7faf 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1086,8 +1086,10 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
*/
#ifdef WIN32
#define sigjmp_buf jmp_buf
-#define sigsetjmp(x,y) setjmp(x)
+#define pg_sigsetjmp(x,y) setjmp(x)
#define siglongjmp longjmp
+#else
+#define pg_sigsetjmp(x,y) sigsetjmp(x,y)
#endif
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 7bfd25a9e9..dc666930b4 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -286,7 +286,7 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
sigjmp_buf *save_exception_stack = PG_exception_stack; \
ErrorContextCallback *save_context_stack = error_context_stack; \
sigjmp_buf local_sigjmp_buf; \
- if (sigsetjmp(local_sigjmp_buf, 0) == 0) \
+ if (pg_sigsetjmp(local_sigjmp_buf, 0) == 0) \
{ \
PG_exception_stack = &local_sigjmp_buf
Robert Haas <robertmhaas@gmail.com> writes:
How about we fix it like this?
That seems pretty invasive; I'm not excited about breaking a lot of
unrelated code (particularly third-party extensions) for plperl's benefit.
Even if we wanted to do that in HEAD, it seems like a nonstarter for
released branches.
An even bigger issue is that if Perl feels free to redefine sigsetjmp,
what other libc calls might they decide to horn in on?
So I was trying to figure a way to not include XSUB.h except in a very
limited part of plperl, like ideally just the .xs files. It's looking
like that would take nontrivial refactoring though :-(. Another problem
is that this critical bit of the library API is in XSUB.h:
#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
# undef aTHX
# undef aTHX_
# define aTHX PERL_GET_THX
# define aTHX_ aTHX,
#endif
As best I can tell, that's absolute brain death on the part of the Perl
crew; it means you can't write working calling code at all without
including XSUB.h, or at least copying-and-pasting this bit out of it.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 07/27/2017 04:33 PM, Tom Lane wrote:
Robert Haas <robertmhaas@gmail.com> writes:
How about we fix it like this?
That seems pretty invasive; I'm not excited about breaking a lot of
unrelated code (particularly third-party extensions) for plperl's benefit.
Even if we wanted to do that in HEAD, it seems like a nonstarter for
released branches.An even bigger issue is that if Perl feels free to redefine sigsetjmp,
what other libc calls might they decide to horn in on?So I was trying to figure a way to not include XSUB.h except in a very
limited part of plperl, like ideally just the .xs files. It's looking
like that would take nontrivial refactoring though :-(. Another problem
is that this critical bit of the library API is in XSUB.h:#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
# undef aTHX
# undef aTHX_
# define aTHX PERL_GET_THX
# define aTHX_ aTHX,
#endifAs best I can tell, that's absolute brain death on the part of the Perl
crew; it means you can't write working calling code at all without
including XSUB.h, or at least copying-and-pasting this bit out of it.
That's the sort of thing that prompted me to ask what was the minimal
set of defines required to fix the original problem (assuming such a
thing exists)
We haven't used PERL_IMPLICIT_CONTEXT to date, and without ill effect.
For example. it's in the ExtUtils::Embed::ccopts for the perl that
jacana and bowerbird happily build and test against.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
On 07/27/2017 04:33 PM, Tom Lane wrote:
So I was trying to figure a way to not include XSUB.h except in a very
limited part of plperl, like ideally just the .xs files. It's looking
like that would take nontrivial refactoring though :-(. Another problem
is that this critical bit of the library API is in XSUB.h:
That's the sort of thing that prompted me to ask what was the minimal
set of defines required to fix the original problem (assuming such a
thing exists)
We haven't used PERL_IMPLICIT_CONTEXT to date, and without ill effect.
For example. it's in the ExtUtils::Embed::ccopts for the perl that
jacana and bowerbird happily build and test against.
Well, actually, PERL_IMPLICIT_CONTEXT is turned on automatically in any
MULTIPLICITY build, and since it changes all the Perl ABIs, we *are*
relying on it. However, after further study of the Perl docs I noticed
that we could dispense with XSUB.h if we defined PERL_NO_GET_CONTEXT
(which turns the quoted stanza into a no-op). That results in needing to
sprinkle plperl.c with "dTHX" declarations, as explained in perlguts.pod.
They're slightly tricky to place correctly, because they load up a pointer
to the current Perl interpreter, so you have to be wary of where to put
them in functions that change interpreters. But I seem to have it working
in the attached patch. (One benefit of doing this extra work is that it
should be a bit more efficient, in that we load up a Perl interpreter
pointer only once per function called, not once per usage therein. We
could remove many of those fetches too, if we wanted to sprinkle the
plperl code with yet more THX droppings; but I left that for another day.)
Armed with that, I got rid of XSUB.h in plperl.c and moved the
PG_TRY-using functions in the .xs files to plperl.c. I think this would
fix Ashutosh's problem, though I am not in a position to try it with a
PERL_IMPLICIT_SYS build here.
regards, tom lane
Attachments:
avoid-XSUB.h-in-plperl.c-v1.patchtext/x-diff; charset=us-ascii; name=avoid-XSUB.h-in-plperl.c-v1.patchDownload
diff --git a/src/pl/plperl/SPI.xs b/src/pl/plperl/SPI.xs
index 0447c50..7651b62 100644
*** a/src/pl/plperl/SPI.xs
--- b/src/pl/plperl/SPI.xs
***************
*** 15,52 ****
#undef _
/* perl stuff */
#include "plperl.h"
#include "plperl_helpers.h"
- /*
- * Interface routine to catch ereports and punt them to Perl
- */
- static void
- do_plperl_return_next(SV *sv)
- {
- MemoryContext oldcontext = CurrentMemoryContext;
-
- PG_TRY();
- {
- plperl_return_next(sv);
- }
- PG_CATCH();
- {
- ErrorData *edata;
-
- /* Must reset elog.c's state */
- MemoryContextSwitchTo(oldcontext);
- edata = CopyErrorData();
- FlushErrorState();
-
- /* Punt the error to Perl */
- croak_cstr(edata->message);
- }
- PG_END_TRY();
- }
-
-
MODULE = PostgreSQL::InServer::SPI PREFIX = spi_
PROTOTYPES: ENABLE
--- 15,25 ----
#undef _
/* perl stuff */
+ #define PG_NEED_PERL_XSUB_H
#include "plperl.h"
#include "plperl_helpers.h"
MODULE = PostgreSQL::InServer::SPI PREFIX = spi_
PROTOTYPES: ENABLE
*************** void
*** 76,82 ****
spi_return_next(rv)
SV *rv;
CODE:
! do_plperl_return_next(rv);
SV *
spi_spi_query(sv)
--- 49,55 ----
spi_return_next(rv)
SV *rv;
CODE:
! plperl_return_next(rv);
SV *
spi_spi_query(sv)
diff --git a/src/pl/plperl/Util.xs b/src/pl/plperl/Util.xs
index dbba0d7..862fec4 100644
*** a/src/pl/plperl/Util.xs
--- b/src/pl/plperl/Util.xs
***************
*** 20,67 ****
#undef _
/* perl stuff */
#include "plperl.h"
#include "plperl_helpers.h"
- /*
- * Implementation of plperl's elog() function
- *
- * If the error level is less than ERROR, we'll just emit the message and
- * return. When it is ERROR, elog() will longjmp, which we catch and
- * turn into a Perl croak(). Note we are assuming that elog() can't have
- * any internal failures that are so bad as to require a transaction abort.
- *
- * This is out-of-line to suppress "might be clobbered by longjmp" warnings.
- */
- static void
- do_util_elog(int level, SV *msg)
- {
- MemoryContext oldcontext = CurrentMemoryContext;
- char * volatile cmsg = NULL;
-
- PG_TRY();
- {
- cmsg = sv2cstr(msg);
- elog(level, "%s", cmsg);
- pfree(cmsg);
- }
- PG_CATCH();
- {
- ErrorData *edata;
-
- /* Must reset elog.c's state */
- MemoryContextSwitchTo(oldcontext);
- edata = CopyErrorData();
- FlushErrorState();
-
- if (cmsg)
- pfree(cmsg);
-
- /* Punt the error to Perl */
- croak_cstr(edata->message);
- }
- PG_END_TRY();
- }
static text *
sv2text(SV *sv)
--- 20,29 ----
#undef _
/* perl stuff */
+ #define PG_NEED_PERL_XSUB_H
#include "plperl.h"
#include "plperl_helpers.h"
static text *
sv2text(SV *sv)
*************** util_elog(level, msg)
*** 105,111 ****
level = ERROR;
if (level < DEBUG5)
level = DEBUG5;
! do_util_elog(level, msg);
SV *
util_quote_literal(sv)
--- 67,73 ----
level = ERROR;
if (level < DEBUG5)
level = DEBUG5;
! plperl_util_elog(level, msg);
SV *
util_quote_literal(sv)
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 5a45e3e..9a26470 100644
*** a/src/pl/plperl/plperl.c
--- b/src/pl/plperl/plperl.c
*************** static void plperl_init_shared_libs(pTHX
*** 285,290 ****
--- 285,291 ----
static void plperl_trusted_init(void);
static void plperl_untrusted_init(void);
static HV *plperl_spi_execute_fetch_result(SPITupleTable *, uint64, int);
+ static void plperl_return_next_internal(SV *sv);
static char *hek2cstr(HE *he);
static SV **hv_store_string(HV *hv, const char *key, SV *val);
static SV **hv_fetch_string(HV *hv, const char *key);
*************** static char *setlocale_perl(int category
*** 303,313 ****
--- 304,326 ----
#endif
/*
+ * Decrement the refcount of the given SV within the active Perl interpreter
+ */
+ static inline void
+ SvREFCNT_dec_current(SV *sv)
+ {
+ dTHX;
+
+ SvREFCNT_dec(sv);
+ }
+
+ /*
* convert a HE (hash entry) key to a cstr in the current database encoding
*/
static char *
hek2cstr(HE *he)
{
+ dTHX;
char *ret;
SV *sv;
*************** select_perl_context(bool trusted)
*** 641,655 ****
* to the database AFTER on_*_init code has run. See
* http://archives.postgresql.org/pgsql-hackers/2010-01/msg02669.php
*/
! newXS("PostgreSQL::InServer::SPI::bootstrap",
! boot_PostgreSQL__InServer__SPI, __FILE__);
! eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
! if (SvTRUE(ERRSV))
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while executing PostgreSQL::InServer::SPI::bootstrap")));
/* Fully initialized, so mark the hashtable entry valid */
interp_desc->interp = interp;
--- 654,672 ----
* to the database AFTER on_*_init code has run. See
* http://archives.postgresql.org/pgsql-hackers/2010-01/msg02669.php
*/
! {
! dTHX;
! newXS("PostgreSQL::InServer::SPI::bootstrap",
! boot_PostgreSQL__InServer__SPI, __FILE__);
!
! eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
! if (SvTRUE(ERRSV))
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while executing PostgreSQL::InServer::SPI::bootstrap")));
! }
/* Fully initialized, so mark the hashtable entry valid */
interp_desc->interp = interp;
*************** plperl_init_interp(void)
*** 792,844 ****
PERL_SET_CONTEXT(plperl);
perl_construct(plperl);
- /* run END blocks in perl_destruct instead of perl_run */
- PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
-
/*
! * Record the original function for the 'require' and 'dofile' opcodes.
! * (They share the same implementation.) Ensure it's used for new
! * interpreters.
*/
- if (!pp_require_orig)
- pp_require_orig = PL_ppaddr[OP_REQUIRE];
- else
{
! PL_ppaddr[OP_REQUIRE] = pp_require_orig;
! PL_ppaddr[OP_DOFILE] = pp_require_orig;
! }
#ifdef PLPERL_ENABLE_OPMASK_EARLY
! /*
! * For regression testing to prove that the PLC_PERLBOOT and PLC_TRUSTED
! * code doesn't even compile any unsafe ops. In future there may be a
! * valid need for them to do so, in which case this could be softened
! * (perhaps moved to plperl_trusted_init()) or removed.
! */
! PL_op_mask = plperl_opmask;
#endif
! if (perl_parse(plperl, plperl_init_shared_libs,
! nargs, embedding, NULL) != 0)
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while parsing Perl initialization")));
! if (perl_run(plperl) != 0)
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while running Perl initialization")));
#ifdef PLPERL_RESTORE_LOCALE
! PLPERL_RESTORE_LOCALE(LC_COLLATE, save_collate);
! PLPERL_RESTORE_LOCALE(LC_CTYPE, save_ctype);
! PLPERL_RESTORE_LOCALE(LC_MONETARY, save_monetary);
! PLPERL_RESTORE_LOCALE(LC_NUMERIC, save_numeric);
! PLPERL_RESTORE_LOCALE(LC_TIME, save_time);
#endif
return plperl;
}
--- 809,870 ----
PERL_SET_CONTEXT(plperl);
perl_construct(plperl);
/*
! * Run END blocks in perl_destruct instead of perl_run. Note that dTHX
! * loads up a pointer to the current interpreter, so we have to postpone
! * it to here rather than put it at the function head.
*/
{
! dTHX;
!
! PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
!
! /*
! * Record the original function for the 'require' and 'dofile'
! * opcodes. (They share the same implementation.) Ensure it's used
! * for new interpreters.
! */
! if (!pp_require_orig)
! pp_require_orig = PL_ppaddr[OP_REQUIRE];
! else
! {
! PL_ppaddr[OP_REQUIRE] = pp_require_orig;
! PL_ppaddr[OP_DOFILE] = pp_require_orig;
! }
#ifdef PLPERL_ENABLE_OPMASK_EARLY
! /*
! * For regression testing to prove that the PLC_PERLBOOT and
! * PLC_TRUSTED code doesn't even compile any unsafe ops. In future
! * there may be a valid need for them to do so, in which case this
! * could be softened (perhaps moved to plperl_trusted_init()) or
! * removed.
! */
! PL_op_mask = plperl_opmask;
#endif
! if (perl_parse(plperl, plperl_init_shared_libs,
! nargs, embedding, NULL) != 0)
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while parsing Perl initialization")));
! if (perl_run(plperl) != 0)
! ereport(ERROR,
! (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
! errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
! errcontext("while running Perl initialization")));
#ifdef PLPERL_RESTORE_LOCALE
! PLPERL_RESTORE_LOCALE(LC_COLLATE, save_collate);
! PLPERL_RESTORE_LOCALE(LC_CTYPE, save_ctype);
! PLPERL_RESTORE_LOCALE(LC_MONETARY, save_monetary);
! PLPERL_RESTORE_LOCALE(LC_NUMERIC, save_numeric);
! PLPERL_RESTORE_LOCALE(LC_TIME, save_time);
#endif
+ }
return plperl;
}
*************** plperl_destroy_interp(PerlInterpreter **
*** 904,909 ****
--- 930,936 ----
* public API so isn't portably available.) Meanwhile END blocks can
* be used to perform manual cleanup.
*/
+ dTHX;
/* Run END blocks - based on perl's perl_destruct() */
if (PL_exit_flags & PERL_EXIT_DESTRUCT_END)
*************** plperl_destroy_interp(PerlInterpreter **
*** 930,935 ****
--- 957,963 ----
static void
plperl_trusted_init(void)
{
+ dTHX;
HV *stash;
SV *sv;
char *key;
*************** plperl_trusted_init(void)
*** 1010,1015 ****
--- 1038,1045 ----
static void
plperl_untrusted_init(void)
{
+ dTHX;
+
/*
* Nothing to do except execute plperl.on_plperlu_init
*/
*************** strip_trailing_ws(const char *msg)
*** 1045,1050 ****
--- 1075,1081 ----
static HeapTuple
plperl_build_tuple_result(HV *perlhash, TupleDesc td)
{
+ dTHX;
Datum *values;
bool *nulls;
HE *he;
*************** plperl_hash_to_datum(SV *src, TupleDesc
*** 1106,1111 ****
--- 1137,1144 ----
static SV *
get_perl_array_ref(SV *sv)
{
+ dTHX;
+
if (SvOK(sv) && SvROK(sv))
{
if (SvTYPE(SvRV(sv)) == SVt_PVAV)
*************** array_to_datum_internal(AV *av, ArrayBui
*** 1134,1139 ****
--- 1167,1173 ----
Oid arraytypid, Oid elemtypid, int32 typmod,
FmgrInfo *finfo, Oid typioparam)
{
+ dTHX;
int i;
int len = av_len(av) + 1;
*************** array_to_datum_internal(AV *av, ArrayBui
*** 1205,1210 ****
--- 1239,1245 ----
static Datum
plperl_array_to_datum(SV *src, Oid typid, int32 typmod)
{
+ dTHX;
ArrayBuildState *astate;
Oid elemtypid;
FmgrInfo finfo;
*************** plperl_sv_to_literal(SV *sv, char *fqtyp
*** 1407,1412 ****
--- 1442,1448 ----
static SV *
plperl_ref_from_pg_array(Datum arg, Oid typid)
{
+ dTHX;
ArrayType *ar = DatumGetArrayTypeP(arg);
Oid elementtype = ARR_ELEMTYPE(ar);
int16 typlen;
*************** plperl_ref_from_pg_array(Datum arg, Oid
*** 1485,1490 ****
--- 1521,1527 ----
static SV *
split_array(plperl_array_info *info, int first, int last, int nest)
{
+ dTHX;
int i;
AV *result;
*************** split_array(plperl_array_info *info, int
*** 1518,1523 ****
--- 1555,1561 ----
static SV *
make_array_ref(plperl_array_info *info, int first, int last)
{
+ dTHX;
int i;
AV *result = newAV();
*************** make_array_ref(plperl_array_info *info,
*** 1555,1560 ****
--- 1593,1599 ----
static SV *
plperl_trigger_build_args(FunctionCallInfo fcinfo)
{
+ dTHX;
TriggerData *tdata;
TupleDesc tupdesc;
int i;
*************** plperl_trigger_build_args(FunctionCallIn
*** 1661,1666 ****
--- 1700,1706 ----
static SV *
plperl_event_trigger_build_args(FunctionCallInfo fcinfo)
{
+ dTHX;
EventTriggerData *tdata;
HV *hv;
*************** plperl_event_trigger_build_args(Function
*** 1678,1683 ****
--- 1718,1724 ----
static HeapTuple
plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
{
+ dTHX;
SV **svp;
HV *hvNew;
HE *he;
*************** plperl_inline_handler(PG_FUNCTION_ARGS)
*** 1874,1880 ****
perlret = plperl_call_perl_func(&desc, &fake_fcinfo);
! SvREFCNT_dec(perlret);
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
--- 1915,1921 ----
perlret = plperl_call_perl_func(&desc, &fake_fcinfo);
! SvREFCNT_dec_current(perlret);
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
*************** plperl_inline_handler(PG_FUNCTION_ARGS)
*** 1882,1888 ****
PG_CATCH();
{
if (desc.reference)
! SvREFCNT_dec(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
PG_RE_THROW();
--- 1923,1929 ----
PG_CATCH();
{
if (desc.reference)
! SvREFCNT_dec_current(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
PG_RE_THROW();
*************** plperl_inline_handler(PG_FUNCTION_ARGS)
*** 1890,1896 ****
PG_END_TRY();
if (desc.reference)
! SvREFCNT_dec(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
--- 1931,1937 ----
PG_END_TRY();
if (desc.reference)
! SvREFCNT_dec_current(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
*************** plperlu_validator(PG_FUNCTION_ARGS)
*** 2018,2023 ****
--- 2059,2065 ----
static void
plperl_create_sub(plperl_proc_desc *prodesc, char *s, Oid fn_oid)
{
+ dTHX;
dSP;
char subname[NAMEDATALEN + 40];
HV *pragma_hv = newHV();
*************** plperl_init_shared_libs(pTHX)
*** 2104,2109 ****
--- 2146,2152 ----
static SV *
plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
{
+ dTHX;
dSP;
SV *retval;
int i;
*************** static SV *
*** 2197,2202 ****
--- 2240,2246 ----
plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo,
SV *td)
{
+ dTHX;
dSP;
SV *retval,
*TDsv;
*************** plperl_call_perl_event_trigger_func(plpe
*** 2265,2270 ****
--- 2309,2315 ----
FunctionCallInfo fcinfo,
SV *td)
{
+ dTHX;
dSP;
SV *retval,
*TDsv;
*************** plperl_func_handler(PG_FUNCTION_ARGS)
*** 2384,2396 ****
sav = get_perl_array_ref(perlret);
if (sav)
{
int i = 0;
SV **svp = 0;
AV *rav = (AV *) SvRV(sav);
while ((svp = av_fetch(rav, i, FALSE)) != NULL)
{
! plperl_return_next(*svp);
i++;
}
}
--- 2429,2442 ----
sav = get_perl_array_ref(perlret);
if (sav)
{
+ dTHX;
int i = 0;
SV **svp = 0;
AV *rav = (AV *) SvRV(sav);
while ((svp = av_fetch(rav, i, FALSE)) != NULL)
{
! plperl_return_next_internal(*svp);
i++;
}
}
*************** plperl_func_handler(PG_FUNCTION_ARGS)
*** 2427,2433 ****
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec(perlret);
return retval;
}
--- 2473,2479 ----
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec_current(perlret);
return retval;
}
*************** plperl_trigger_handler(PG_FUNCTION_ARGS)
*** 2538,2546 ****
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec(svTD);
if (perlret)
! SvREFCNT_dec(perlret);
return retval;
}
--- 2584,2592 ----
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec_current(svTD);
if (perlret)
! SvREFCNT_dec_current(perlret);
return retval;
}
*************** plperl_event_trigger_handler(PG_FUNCTION
*** 2579,2587 ****
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec(svTD);
!
! return;
}
--- 2625,2631 ----
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
! SvREFCNT_dec_current(svTD);
}
*************** free_plperl_function(plperl_proc_desc *p
*** 2624,2630 ****
plperl_interp_desc *oldinterp = plperl_active_interp;
activate_interpreter(prodesc->interp);
! SvREFCNT_dec(prodesc->reference);
activate_interpreter(oldinterp);
}
/* Release all PG-owned data for this proc */
--- 2668,2674 ----
plperl_interp_desc *oldinterp = plperl_active_interp;
activate_interpreter(prodesc->interp);
! SvREFCNT_dec_current(prodesc->reference);
activate_interpreter(oldinterp);
}
/* Release all PG-owned data for this proc */
*************** plperl_hash_from_datum(Datum attr)
*** 2949,2954 ****
--- 2993,2999 ----
static SV *
plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
{
+ dTHX;
HV *hv;
int i;
*************** static HV *
*** 3094,3099 ****
--- 3139,3145 ----
plperl_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 processed,
int status)
{
+ dTHX;
HV *result;
check_spi_usage_allowed();
*************** plperl_spi_execute_fetch_result(SPITuple
*** 3137,3152 ****
/*
! * Note: plperl_return_next is called both in Postgres and Perl contexts.
! * We report any errors in Postgres fashion (via ereport). If called in
! * Perl context, it is SPI.xs's responsibility to catch the error and
! * convert to a Perl error. We assume (perhaps without adequate justification)
! * that we need not abort the current transaction if the Perl code traps the
! * error.
*/
void
plperl_return_next(SV *sv)
{
plperl_proc_desc *prodesc;
FunctionCallInfo fcinfo;
ReturnSetInfo *rsi;
--- 3183,3223 ----
/*
! * plperl_return_next catches any error and converts it to a Perl error.
! * We assume (perhaps without adequate justification) that we need not abort
! * the current transaction if the Perl code traps the error.
*/
void
plperl_return_next(SV *sv)
{
+ MemoryContext oldcontext = CurrentMemoryContext;
+
+ PG_TRY();
+ {
+ plperl_return_next_internal(sv);
+ }
+ PG_CATCH();
+ {
+ ErrorData *edata;
+
+ /* Must reset elog.c's state */
+ MemoryContextSwitchTo(oldcontext);
+ edata = CopyErrorData();
+ FlushErrorState();
+
+ /* Punt the error to Perl */
+ croak_cstr(edata->message);
+ }
+ PG_END_TRY();
+ }
+
+ /*
+ * plperl_return_next_internal reports any errors in Postgres fashion
+ * (via ereport).
+ */
+ static void
+ plperl_return_next_internal(SV *sv)
+ {
plperl_proc_desc *prodesc;
FunctionCallInfo fcinfo;
ReturnSetInfo *rsi;
*************** plperl_spi_fetchrow(char *cursor)
*** 3336,3341 ****
--- 3407,3413 ----
PG_TRY();
{
+ dTHX;
Portal p = SPI_cursor_find(cursor);
if (!p)
*************** plperl_spi_exec_prepared(char *query, HV
*** 3577,3582 ****
--- 3649,3656 ----
PG_TRY();
{
+ dTHX;
+
/************************************************************
* Fetch the saved plan descriptor, see if it's o.k.
************************************************************/
*************** plperl_spi_freeplan(char *query)
*** 3822,3833 ****
--- 3896,3949 ----
}
/*
+ * Implementation of plperl's elog() function
+ *
+ * If the error level is less than ERROR, we'll just emit the message and
+ * return. When it is ERROR, elog() will longjmp, which we catch and
+ * turn into a Perl croak(). Note we are assuming that elog() can't have
+ * any internal failures that are so bad as to require a transaction abort.
+ *
+ * The main reason this is out-of-line is to avoid conflicts between XSUB.h
+ * and the PG_TRY macros.
+ */
+ void
+ plperl_util_elog(int level, SV *msg)
+ {
+ MemoryContext oldcontext = CurrentMemoryContext;
+ char *volatile cmsg = NULL;
+
+ PG_TRY();
+ {
+ cmsg = sv2cstr(msg);
+ elog(level, "%s", cmsg);
+ pfree(cmsg);
+ }
+ PG_CATCH();
+ {
+ ErrorData *edata;
+
+ /* Must reset elog.c's state */
+ MemoryContextSwitchTo(oldcontext);
+ edata = CopyErrorData();
+ FlushErrorState();
+
+ if (cmsg)
+ pfree(cmsg);
+
+ /* Punt the error to Perl */
+ croak_cstr(edata->message);
+ }
+ PG_END_TRY();
+ }
+
+ /*
* Store an SV into a hash table under a key that is a string assumed to be
* in the current database's encoding.
*/
static SV **
hv_store_string(HV *hv, const char *key, SV *val)
{
+ dTHX;
int32 hlen;
char *hkey;
SV **ret;
*************** hv_store_string(HV *hv, const char *key,
*** 3854,3859 ****
--- 3970,3976 ----
static SV **
hv_fetch_string(HV *hv, const char *key)
{
+ dTHX;
int32 hlen;
char *hkey;
SV **ret;
diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h
index eecd192..3f3cce9 100644
*** a/src/pl/plperl/plperl.h
--- b/src/pl/plperl/plperl.h
***************
*** 44,52 ****
--- 44,60 ----
/* required for perl API */
+ #define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
+
+ /*
+ * We want to include this only within .xs files, but it must come before
+ * ppport.h, so use a #define flag to control inclusion.
+ */
+ #ifdef PG_NEED_PERL_XSUB_H
#include "XSUB.h"
+ #endif
/* put back our snprintf and vsnprintf */
#ifdef USE_REPL_SNPRINTF
*************** SV *plperl_spi_query_prepared(char *
*** 106,110 ****
--- 114,119 ----
void plperl_spi_freeplan(char *);
void plperl_spi_cursor_close(char *);
char *plperl_sv_to_literal(SV *, char *);
+ void plperl_util_elog(int level, SV *msg);
#endif /* PL_PERL_H */
diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h
index 76124ed..5acac60 100644
*** a/src/pl/plperl/plperl_helpers.h
--- b/src/pl/plperl/plperl_helpers.h
*************** sv2cstr(SV *sv)
*** 54,59 ****
--- 54,61 ----
*res;
STRLEN len;
+ dTHX;
+
/*
* get a utf8 encoded char * out of perl. *note* it may not be valid utf8!
*/
*************** cstr2sv(const char *str)
*** 110,115 ****
--- 112,119 ----
SV *sv;
char *utf8_str;
+ dTHX;
+
/* no conversion when SQL_ASCII */
if (GetDatabaseEncoding() == PG_SQL_ASCII)
return newSVpv(str, 0);
*************** cstr2sv(const char *str)
*** 134,139 ****
--- 138,145 ----
static inline void
croak_cstr(const char *str)
{
+ dTHX;
+
#ifdef croak_sv
/* Use sv_2mortal() to be sure the transient SV gets freed */
croak_sv(sv_2mortal(cstr2sv(str)));
Hi,
On Fri, Jul 28, 2017 at 4:20 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
On 07/27/2017 04:33 PM, Tom Lane wrote:
So I was trying to figure a way to not include XSUB.h except in a very
limited part of plperl, like ideally just the .xs files. It's looking
like that would take nontrivial refactoring though :-(. Another problem
is that this critical bit of the library API is in XSUB.h:That's the sort of thing that prompted me to ask what was the minimal
set of defines required to fix the original problem (assuming such a
thing exists)
We haven't used PERL_IMPLICIT_CONTEXT to date, and without ill effect.
For example. it's in the ExtUtils::Embed::ccopts for the perl that
jacana and bowerbird happily build and test against.Well, actually, PERL_IMPLICIT_CONTEXT is turned on automatically in any
MULTIPLICITY build, and since it changes all the Perl ABIs, we *are*
relying on it. However, after further study of the Perl docs I noticed
that we could dispense with XSUB.h if we defined PERL_NO_GET_CONTEXT
(which turns the quoted stanza into a no-op). That results in needing to
sprinkle plperl.c with "dTHX" declarations, as explained in perlguts.pod.
They're slightly tricky to place correctly, because they load up a pointer
to the current Perl interpreter, so you have to be wary of where to put
them in functions that change interpreters. But I seem to have it working
in the attached patch. (One benefit of doing this extra work is that it
should be a bit more efficient, in that we load up a Perl interpreter
pointer only once per function called, not once per usage therein. We
could remove many of those fetches too, if we wanted to sprinkle the
plperl code with yet more THX droppings; but I left that for another day.)Armed with that, I got rid of XSUB.h in plperl.c and moved the
PG_TRY-using functions in the .xs files to plperl.c. I think this would
fix Ashutosh's problem, though I am not in a position to try it with a
PERL_IMPLICIT_SYS build here.
Thanks for the patch. I am seeing some compilation errors on Windows
with the patch. Below are the errors observed,
1>ClCompile:
1> plperl.c
1>src/pl/plperl/plperl.c(4051): error C2065: 'my_perl' : undeclared identifier
2>ClCompile:
2> hstore_plperl.c
2>contrib/hstore_plperl/hstore_plperl.c(77): error C2065: 'my_perl' :
undeclared identifier
I did spent some time to find reason for these compilation errors and
could eventually find that some of the Windows specific functions
inside plperl module are calling Perl APIs without fetching the perl
interpreter's context using dTHX. Please note that, we have now
defined PERL_NO_GET_CONTEXT macro before including the Perl headers in
plperl.h file which means any plperl function calling Perl APIs should
try to fetch the perl interpreter context variable 'my_perl' at the
start of the function using dTHX but, we were not doing that for
'setlocale_perl', 'hstore_to_plperl' and 'plperl_to_hstore' functions.
I have corrected this and attached is the new version of patch.
Moreover, I have also tested this patch along with the patch to import
switches used by perl into plperl and together it fixes the server
crash issue. Also, now, the interpreter size in both perl and plperl
module are the same thereby generating the same key on both plperl and
perl module. Thanks.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Attachments:
avoid-XSUB.h-in-plperl.c-v2.patchapplication/octet-stream; name=avoid-XSUB.h-in-plperl.c-v2.patchDownload
diff --git a/contrib/hstore_plperl/hstore_plperl.c b/contrib/hstore_plperl/hstore_plperl.c
index 480212f..3489ece 100644
--- a/contrib/hstore_plperl/hstore_plperl.c
+++ b/contrib/hstore_plperl/hstore_plperl.c
@@ -73,6 +73,7 @@ hstore_to_plperl(PG_FUNCTION_ARGS)
char *base = STRPTR(in);
HEntry *entries = ARRPTR(in);
HV *hv;
+ dTHX;
hv = newHV();
@@ -106,6 +107,7 @@ plperl_to_hstore(PG_FUNCTION_ARGS)
int32 pcount;
HStore *out;
Pairs *pairs;
+ dTHX;
hv = (HV *) SvRV((SV *) PG_GETARG_POINTER(0));
diff --git a/src/pl/plperl/SPI.xs b/src/pl/plperl/SPI.xs
index 0447c50..7651b62 100644
--- a/src/pl/plperl/SPI.xs
+++ b/src/pl/plperl/SPI.xs
@@ -15,38 +15,11 @@
#undef _
/* perl stuff */
+#define PG_NEED_PERL_XSUB_H
#include "plperl.h"
#include "plperl_helpers.h"
-/*
- * Interface routine to catch ereports and punt them to Perl
- */
-static void
-do_plperl_return_next(SV *sv)
-{
- MemoryContext oldcontext = CurrentMemoryContext;
-
- PG_TRY();
- {
- plperl_return_next(sv);
- }
- PG_CATCH();
- {
- ErrorData *edata;
-
- /* Must reset elog.c's state */
- MemoryContextSwitchTo(oldcontext);
- edata = CopyErrorData();
- FlushErrorState();
-
- /* Punt the error to Perl */
- croak_cstr(edata->message);
- }
- PG_END_TRY();
-}
-
-
MODULE = PostgreSQL::InServer::SPI PREFIX = spi_
PROTOTYPES: ENABLE
@@ -76,7 +49,7 @@ void
spi_return_next(rv)
SV *rv;
CODE:
- do_plperl_return_next(rv);
+ plperl_return_next(rv);
SV *
spi_spi_query(sv)
diff --git a/src/pl/plperl/Util.xs b/src/pl/plperl/Util.xs
index dbba0d7..862fec4 100644
--- a/src/pl/plperl/Util.xs
+++ b/src/pl/plperl/Util.xs
@@ -20,48 +20,10 @@
#undef _
/* perl stuff */
+#define PG_NEED_PERL_XSUB_H
#include "plperl.h"
#include "plperl_helpers.h"
-/*
- * Implementation of plperl's elog() function
- *
- * If the error level is less than ERROR, we'll just emit the message and
- * return. When it is ERROR, elog() will longjmp, which we catch and
- * turn into a Perl croak(). Note we are assuming that elog() can't have
- * any internal failures that are so bad as to require a transaction abort.
- *
- * This is out-of-line to suppress "might be clobbered by longjmp" warnings.
- */
-static void
-do_util_elog(int level, SV *msg)
-{
- MemoryContext oldcontext = CurrentMemoryContext;
- char * volatile cmsg = NULL;
-
- PG_TRY();
- {
- cmsg = sv2cstr(msg);
- elog(level, "%s", cmsg);
- pfree(cmsg);
- }
- PG_CATCH();
- {
- ErrorData *edata;
-
- /* Must reset elog.c's state */
- MemoryContextSwitchTo(oldcontext);
- edata = CopyErrorData();
- FlushErrorState();
-
- if (cmsg)
- pfree(cmsg);
-
- /* Punt the error to Perl */
- croak_cstr(edata->message);
- }
- PG_END_TRY();
-}
static text *
sv2text(SV *sv)
@@ -105,7 +67,7 @@ util_elog(level, msg)
level = ERROR;
if (level < DEBUG5)
level = DEBUG5;
- do_util_elog(level, msg);
+ plperl_util_elog(level, msg);
SV *
util_quote_literal(sv)
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 5a45e3e..cbac1af 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -285,6 +285,7 @@ static void plperl_init_shared_libs(pTHX);
static void plperl_trusted_init(void);
static void plperl_untrusted_init(void);
static HV *plperl_spi_execute_fetch_result(SPITupleTable *, uint64, int);
+static void plperl_return_next_internal(SV *sv);
static char *hek2cstr(HE *he);
static SV **hv_store_string(HV *hv, const char *key, SV *val);
static SV **hv_fetch_string(HV *hv, const char *key);
@@ -303,11 +304,23 @@ static char *setlocale_perl(int category, char *locale);
#endif
/*
+ * Decrement the refcount of the given SV within the active Perl interpreter
+ */
+static inline void
+SvREFCNT_dec_current(SV *sv)
+{
+ dTHX;
+
+ SvREFCNT_dec(sv);
+}
+
+/*
* convert a HE (hash entry) key to a cstr in the current database encoding
*/
static char *
hek2cstr(HE *he)
{
+ dTHX;
char *ret;
SV *sv;
@@ -641,15 +654,19 @@ select_perl_context(bool trusted)
* to the database AFTER on_*_init code has run. See
* http://archives.postgresql.org/pgsql-hackers/2010-01/msg02669.php
*/
- newXS("PostgreSQL::InServer::SPI::bootstrap",
- boot_PostgreSQL__InServer__SPI, __FILE__);
+ {
+ dTHX;
- eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
- if (SvTRUE(ERRSV))
- ereport(ERROR,
- (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
- errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
- errcontext("while executing PostgreSQL::InServer::SPI::bootstrap")));
+ newXS("PostgreSQL::InServer::SPI::bootstrap",
+ boot_PostgreSQL__InServer__SPI, __FILE__);
+
+ eval_pv("PostgreSQL::InServer::SPI::bootstrap()", FALSE);
+ if (SvTRUE(ERRSV))
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ errcontext("while executing PostgreSQL::InServer::SPI::bootstrap")));
+ }
/* Fully initialized, so mark the hashtable entry valid */
interp_desc->interp = interp;
@@ -792,53 +809,62 @@ plperl_init_interp(void)
PERL_SET_CONTEXT(plperl);
perl_construct(plperl);
- /* run END blocks in perl_destruct instead of perl_run */
- PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
-
/*
- * Record the original function for the 'require' and 'dofile' opcodes.
- * (They share the same implementation.) Ensure it's used for new
- * interpreters.
+ * Run END blocks in perl_destruct instead of perl_run. Note that dTHX
+ * loads up a pointer to the current interpreter, so we have to postpone
+ * it to here rather than put it at the function head.
*/
- if (!pp_require_orig)
- pp_require_orig = PL_ppaddr[OP_REQUIRE];
- else
{
- PL_ppaddr[OP_REQUIRE] = pp_require_orig;
- PL_ppaddr[OP_DOFILE] = pp_require_orig;
- }
+ dTHX;
+
+ PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
+
+ /*
+ * Record the original function for the 'require' and 'dofile'
+ * opcodes. (They share the same implementation.) Ensure it's used
+ * for new interpreters.
+ */
+ if (!pp_require_orig)
+ pp_require_orig = PL_ppaddr[OP_REQUIRE];
+ else
+ {
+ PL_ppaddr[OP_REQUIRE] = pp_require_orig;
+ PL_ppaddr[OP_DOFILE] = pp_require_orig;
+ }
#ifdef PLPERL_ENABLE_OPMASK_EARLY
- /*
- * For regression testing to prove that the PLC_PERLBOOT and PLC_TRUSTED
- * code doesn't even compile any unsafe ops. In future there may be a
- * valid need for them to do so, in which case this could be softened
- * (perhaps moved to plperl_trusted_init()) or removed.
- */
- PL_op_mask = plperl_opmask;
+ /*
+ * For regression testing to prove that the PLC_PERLBOOT and
+ * PLC_TRUSTED code doesn't even compile any unsafe ops. In future
+ * there may be a valid need for them to do so, in which case this
+ * could be softened (perhaps moved to plperl_trusted_init()) or
+ * removed.
+ */
+ PL_op_mask = plperl_opmask;
#endif
- if (perl_parse(plperl, plperl_init_shared_libs,
- nargs, embedding, NULL) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
- errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
- errcontext("while parsing Perl initialization")));
+ if (perl_parse(plperl, plperl_init_shared_libs,
+ nargs, embedding, NULL) != 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ errcontext("while parsing Perl initialization")));
- if (perl_run(plperl) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
- errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
- errcontext("while running Perl initialization")));
+ if (perl_run(plperl) != 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
+ errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))),
+ errcontext("while running Perl initialization")));
#ifdef PLPERL_RESTORE_LOCALE
- PLPERL_RESTORE_LOCALE(LC_COLLATE, save_collate);
- PLPERL_RESTORE_LOCALE(LC_CTYPE, save_ctype);
- PLPERL_RESTORE_LOCALE(LC_MONETARY, save_monetary);
- PLPERL_RESTORE_LOCALE(LC_NUMERIC, save_numeric);
- PLPERL_RESTORE_LOCALE(LC_TIME, save_time);
+ PLPERL_RESTORE_LOCALE(LC_COLLATE, save_collate);
+ PLPERL_RESTORE_LOCALE(LC_CTYPE, save_ctype);
+ PLPERL_RESTORE_LOCALE(LC_MONETARY, save_monetary);
+ PLPERL_RESTORE_LOCALE(LC_NUMERIC, save_numeric);
+ PLPERL_RESTORE_LOCALE(LC_TIME, save_time);
#endif
+ }
return plperl;
}
@@ -904,6 +930,7 @@ plperl_destroy_interp(PerlInterpreter **interp)
* public API so isn't portably available.) Meanwhile END blocks can
* be used to perform manual cleanup.
*/
+ dTHX;
/* Run END blocks - based on perl's perl_destruct() */
if (PL_exit_flags & PERL_EXIT_DESTRUCT_END)
@@ -930,6 +957,7 @@ plperl_destroy_interp(PerlInterpreter **interp)
static void
plperl_trusted_init(void)
{
+ dTHX;
HV *stash;
SV *sv;
char *key;
@@ -1010,6 +1038,8 @@ plperl_trusted_init(void)
static void
plperl_untrusted_init(void)
{
+ dTHX;
+
/*
* Nothing to do except execute plperl.on_plperlu_init
*/
@@ -1045,6 +1075,7 @@ strip_trailing_ws(const char *msg)
static HeapTuple
plperl_build_tuple_result(HV *perlhash, TupleDesc td)
{
+ dTHX;
Datum *values;
bool *nulls;
HE *he;
@@ -1106,6 +1137,8 @@ plperl_hash_to_datum(SV *src, TupleDesc td)
static SV *
get_perl_array_ref(SV *sv)
{
+ dTHX;
+
if (SvOK(sv) && SvROK(sv))
{
if (SvTYPE(SvRV(sv)) == SVt_PVAV)
@@ -1134,6 +1167,7 @@ array_to_datum_internal(AV *av, ArrayBuildState *astate,
Oid arraytypid, Oid elemtypid, int32 typmod,
FmgrInfo *finfo, Oid typioparam)
{
+ dTHX;
int i;
int len = av_len(av) + 1;
@@ -1205,6 +1239,7 @@ array_to_datum_internal(AV *av, ArrayBuildState *astate,
static Datum
plperl_array_to_datum(SV *src, Oid typid, int32 typmod)
{
+ dTHX;
ArrayBuildState *astate;
Oid elemtypid;
FmgrInfo finfo;
@@ -1407,6 +1442,7 @@ plperl_sv_to_literal(SV *sv, char *fqtypename)
static SV *
plperl_ref_from_pg_array(Datum arg, Oid typid)
{
+ dTHX;
ArrayType *ar = DatumGetArrayTypeP(arg);
Oid elementtype = ARR_ELEMTYPE(ar);
int16 typlen;
@@ -1485,6 +1521,7 @@ plperl_ref_from_pg_array(Datum arg, Oid typid)
static SV *
split_array(plperl_array_info *info, int first, int last, int nest)
{
+ dTHX;
int i;
AV *result;
@@ -1518,6 +1555,7 @@ split_array(plperl_array_info *info, int first, int last, int nest)
static SV *
make_array_ref(plperl_array_info *info, int first, int last)
{
+ dTHX;
int i;
AV *result = newAV();
@@ -1555,6 +1593,7 @@ make_array_ref(plperl_array_info *info, int first, int last)
static SV *
plperl_trigger_build_args(FunctionCallInfo fcinfo)
{
+ dTHX;
TriggerData *tdata;
TupleDesc tupdesc;
int i;
@@ -1661,6 +1700,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
static SV *
plperl_event_trigger_build_args(FunctionCallInfo fcinfo)
{
+ dTHX;
EventTriggerData *tdata;
HV *hv;
@@ -1678,6 +1718,7 @@ plperl_event_trigger_build_args(FunctionCallInfo fcinfo)
static HeapTuple
plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
{
+ dTHX;
SV **svp;
HV *hvNew;
HE *he;
@@ -1874,7 +1915,7 @@ plperl_inline_handler(PG_FUNCTION_ARGS)
perlret = plperl_call_perl_func(&desc, &fake_fcinfo);
- SvREFCNT_dec(perlret);
+ SvREFCNT_dec_current(perlret);
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
@@ -1882,7 +1923,7 @@ plperl_inline_handler(PG_FUNCTION_ARGS)
PG_CATCH();
{
if (desc.reference)
- SvREFCNT_dec(desc.reference);
+ SvREFCNT_dec_current(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
PG_RE_THROW();
@@ -1890,7 +1931,7 @@ plperl_inline_handler(PG_FUNCTION_ARGS)
PG_END_TRY();
if (desc.reference)
- SvREFCNT_dec(desc.reference);
+ SvREFCNT_dec_current(desc.reference);
current_call_data = save_call_data;
activate_interpreter(oldinterp);
@@ -2018,6 +2059,7 @@ plperlu_validator(PG_FUNCTION_ARGS)
static void
plperl_create_sub(plperl_proc_desc *prodesc, char *s, Oid fn_oid)
{
+ dTHX;
dSP;
char subname[NAMEDATALEN + 40];
HV *pragma_hv = newHV();
@@ -2104,6 +2146,7 @@ plperl_init_shared_libs(pTHX)
static SV *
plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
{
+ dTHX;
dSP;
SV *retval;
int i;
@@ -2197,6 +2240,7 @@ static SV *
plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo,
SV *td)
{
+ dTHX;
dSP;
SV *retval,
*TDsv;
@@ -2265,6 +2309,7 @@ plperl_call_perl_event_trigger_func(plperl_proc_desc *desc,
FunctionCallInfo fcinfo,
SV *td)
{
+ dTHX;
dSP;
SV *retval,
*TDsv;
@@ -2384,13 +2429,14 @@ plperl_func_handler(PG_FUNCTION_ARGS)
sav = get_perl_array_ref(perlret);
if (sav)
{
+ dTHX;
int i = 0;
SV **svp = 0;
AV *rav = (AV *) SvRV(sav);
while ((svp = av_fetch(rav, i, FALSE)) != NULL)
{
- plperl_return_next(*svp);
+ plperl_return_next_internal(*svp);
i++;
}
}
@@ -2427,7 +2473,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
- SvREFCNT_dec(perlret);
+ SvREFCNT_dec_current(perlret);
return retval;
}
@@ -2538,9 +2584,9 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
- SvREFCNT_dec(svTD);
+ SvREFCNT_dec_current(svTD);
if (perlret)
- SvREFCNT_dec(perlret);
+ SvREFCNT_dec_current(perlret);
return retval;
}
@@ -2579,9 +2625,7 @@ plperl_event_trigger_handler(PG_FUNCTION_ARGS)
/* Restore the previous error callback */
error_context_stack = pl_error_context.previous;
- SvREFCNT_dec(svTD);
-
- return;
+ SvREFCNT_dec_current(svTD);
}
@@ -2624,7 +2668,7 @@ free_plperl_function(plperl_proc_desc *prodesc)
plperl_interp_desc *oldinterp = plperl_active_interp;
activate_interpreter(prodesc->interp);
- SvREFCNT_dec(prodesc->reference);
+ SvREFCNT_dec_current(prodesc->reference);
activate_interpreter(oldinterp);
}
/* Release all PG-owned data for this proc */
@@ -2949,6 +2993,7 @@ plperl_hash_from_datum(Datum attr)
static SV *
plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
{
+ dTHX;
HV *hv;
int i;
@@ -3094,6 +3139,7 @@ static HV *
plperl_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 processed,
int status)
{
+ dTHX;
HV *result;
check_spi_usage_allowed();
@@ -3137,16 +3183,41 @@ plperl_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 processed,
/*
- * Note: plperl_return_next is called both in Postgres and Perl contexts.
- * We report any errors in Postgres fashion (via ereport). If called in
- * Perl context, it is SPI.xs's responsibility to catch the error and
- * convert to a Perl error. We assume (perhaps without adequate justification)
- * that we need not abort the current transaction if the Perl code traps the
- * error.
+ * plperl_return_next catches any error and converts it to a Perl error.
+ * We assume (perhaps without adequate justification) that we need not abort
+ * the current transaction if the Perl code traps the error.
*/
void
plperl_return_next(SV *sv)
{
+ MemoryContext oldcontext = CurrentMemoryContext;
+
+ PG_TRY();
+ {
+ plperl_return_next_internal(sv);
+ }
+ PG_CATCH();
+ {
+ ErrorData *edata;
+
+ /* Must reset elog.c's state */
+ MemoryContextSwitchTo(oldcontext);
+ edata = CopyErrorData();
+ FlushErrorState();
+
+ /* Punt the error to Perl */
+ croak_cstr(edata->message);
+ }
+ PG_END_TRY();
+}
+
+/*
+ * plperl_return_next_internal reports any errors in Postgres fashion
+ * (via ereport).
+ */
+static void
+plperl_return_next_internal(SV *sv)
+{
plperl_proc_desc *prodesc;
FunctionCallInfo fcinfo;
ReturnSetInfo *rsi;
@@ -3336,6 +3407,7 @@ plperl_spi_fetchrow(char *cursor)
PG_TRY();
{
+ dTHX;
Portal p = SPI_cursor_find(cursor);
if (!p)
@@ -3577,6 +3649,8 @@ plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv)
PG_TRY();
{
+ dTHX;
+
/************************************************************
* Fetch the saved plan descriptor, see if it's o.k.
************************************************************/
@@ -3822,12 +3896,54 @@ plperl_spi_freeplan(char *query)
}
/*
+ * Implementation of plperl's elog() function
+ *
+ * If the error level is less than ERROR, we'll just emit the message and
+ * return. When it is ERROR, elog() will longjmp, which we catch and
+ * turn into a Perl croak(). Note we are assuming that elog() can't have
+ * any internal failures that are so bad as to require a transaction abort.
+ *
+ * The main reason this is out-of-line is to avoid conflicts between XSUB.h
+ * and the PG_TRY macros.
+ */
+void
+plperl_util_elog(int level, SV *msg)
+{
+ MemoryContext oldcontext = CurrentMemoryContext;
+ char *volatile cmsg = NULL;
+
+ PG_TRY();
+ {
+ cmsg = sv2cstr(msg);
+ elog(level, "%s", cmsg);
+ pfree(cmsg);
+ }
+ PG_CATCH();
+ {
+ ErrorData *edata;
+
+ /* Must reset elog.c's state */
+ MemoryContextSwitchTo(oldcontext);
+ edata = CopyErrorData();
+ FlushErrorState();
+
+ if (cmsg)
+ pfree(cmsg);
+
+ /* Punt the error to Perl */
+ croak_cstr(edata->message);
+ }
+ PG_END_TRY();
+}
+
+/*
* Store an SV into a hash table under a key that is a string assumed to be
* in the current database's encoding.
*/
static SV **
hv_store_string(HV *hv, const char *key, SV *val)
{
+ dTHX;
int32 hlen;
char *hkey;
SV **ret;
@@ -3854,6 +3970,7 @@ hv_store_string(HV *hv, const char *key, SV *val)
static SV **
hv_fetch_string(HV *hv, const char *key)
{
+ dTHX;
int32 hlen;
char *hkey;
SV **ret;
@@ -3913,6 +4030,7 @@ static char *
setlocale_perl(int category, char *locale)
{
char *RETVAL = setlocale(category, locale);
+ dTHX;
if (RETVAL)
{
diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h
index eecd192..3f3cce9 100644
--- a/src/pl/plperl/plperl.h
+++ b/src/pl/plperl/plperl.h
@@ -44,9 +44,17 @@
/* required for perl API */
+#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
+
+/*
+ * We want to include this only within .xs files, but it must come before
+ * ppport.h, so use a #define flag to control inclusion.
+ */
+#ifdef PG_NEED_PERL_XSUB_H
#include "XSUB.h"
+#endif
/* put back our snprintf and vsnprintf */
#ifdef USE_REPL_SNPRINTF
@@ -106,5 +114,6 @@ SV *plperl_spi_query_prepared(char *, int, SV **);
void plperl_spi_freeplan(char *);
void plperl_spi_cursor_close(char *);
char *plperl_sv_to_literal(SV *, char *);
+void plperl_util_elog(int level, SV *msg);
#endif /* PL_PERL_H */
diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h
index 76124ed..5acac60 100644
--- a/src/pl/plperl/plperl_helpers.h
+++ b/src/pl/plperl/plperl_helpers.h
@@ -54,6 +54,8 @@ sv2cstr(SV *sv)
*res;
STRLEN len;
+ dTHX;
+
/*
* get a utf8 encoded char * out of perl. *note* it may not be valid utf8!
*/
@@ -110,6 +112,8 @@ cstr2sv(const char *str)
SV *sv;
char *utf8_str;
+ dTHX;
+
/* no conversion when SQL_ASCII */
if (GetDatabaseEncoding() == PG_SQL_ASCII)
return newSVpv(str, 0);
@@ -134,6 +138,8 @@ cstr2sv(const char *str)
static inline void
croak_cstr(const char *str)
{
+ dTHX;
+
#ifdef croak_sv
/* Use sv_2mortal() to be sure the transient SV gets freed */
croak_sv(sv_2mortal(cstr2sv(str)));
plperl_win_v2.patchapplication/octet-stream; name=plperl_win_v2.patchDownload
From 518bdc92b619b4d1c906431854e9728ddc955474 Mon Sep 17 00:00:00 2001
From: Ashutosh <ashu.coek@gmail.com>
Date: Thu, 27 Jul 2017 18:24:19 +0530
Subject: [PATCH] Windows fix
---
src/tools/msvc/Mkvcbuild.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index e0bf607..f1a991b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -518,6 +518,16 @@ sub mkvcbuild
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ foreach my $f (split(" ",$Config{ccflags}))
+ {
+ if ($f =~ /^-D/)
+ {
+ $f =~ s/\-D//;
+ $plperl->AddDefine($f);
+ }
+ }
+
foreach my $xs ('SPI.xs', 'Util.xs')
{
(my $xsc = $xs) =~ s/\.xs/.c/;
--
2.10.2.windows.1
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Thanks for the patch. I am seeing some compilation errors on Windows
with the patch. Below are the errors observed,
...
I did spent some time to find reason for these compilation errors and
could eventually find that some of the Windows specific functions
inside plperl module are calling Perl APIs without fetching the perl
interpreter's context using dTHX.
Ah, thanks. I just stuck that in where compiler errors were telling
me to, so I didn't realize there were Windows-specific functions to
worry about.
Moreover, I have also tested this patch along with the patch to import
switches used by perl into plperl and together it fixes the server
crash issue. Also, now, the interpreter size in both perl and plperl
module are the same thereby generating the same key on both plperl and
perl module. Thanks.
Excellent. So this looks like the avenue to pursue.
As far as the question of which symbols to import goes: on my own
machines I'm seeing a lot of things like
$ perl -MConfig -e 'print $Config{ccflags}'
-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
$ perl -MConfig -e 'print $Config{ccflags}'
-Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DDEBUGGING -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
I'm really quite afraid to import symbols like _LARGEFILE_SOURCE and
_FILE_OFFSET_BITS into plperl; those *will* break things if they
are different from what core Postgres is built with. Moreover,
I came across a relevant data structure in perl.h:
/* These are all the compile time options that affect binary compatibility.
Other compile time options that are binary compatible are in perl.c
Both are combined for the output of perl -V
However, this string will be embedded in any shared perl library, which will
allow us add a comparison check in perlmain.c in the near future. */
#ifdef DOINIT
EXTCONST char PL_bincompat_options[] =
# ifdef DEBUG_LEAKING_SCALARS
" DEBUG_LEAKING_SCALARS"
# endif
# ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
" DEBUG_LEAKING_SCALARS_FORK_DUMP"
# endif
# ifdef FAKE_THREADS
" FAKE_THREADS"
# endif
# ifdef MULTIPLICITY
" MULTIPLICITY"
# endif
... lots more ...
Assuming that the Perl crew know what they're doing and this list is
complete, I notice that not one of the symbols they show as relevant
starts with an underscore. So I'm thinking that my previous semi-
joking idea of absorbing only -D switches for names that *don't*
start with an underscore was actually a good solution. If that
turns out to not be enough of a filter, we could consider looking
into perl.h to extract the set of symbols tested in building
PL_bincompat_options and then intersecting that with what we get
from Perl's ccflags. But that would be a lot more complex, so
I'd rather go with the simpler filter rule for now.
(BTW, you never did tell us exactly what defines you're getting
out of Perl's flags on the problem installation.)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Fri, Jul 28, 2017 at 7:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
Thanks for the patch. I am seeing some compilation errors on Windows
with the patch. Below are the errors observed,
...
I did spent some time to find reason for these compilation errors and
could eventually find that some of the Windows specific functions
inside plperl module are calling Perl APIs without fetching the perl
interpreter's context using dTHX.Ah, thanks. I just stuck that in where compiler errors were telling
me to, so I didn't realize there were Windows-specific functions to
worry about.Moreover, I have also tested this patch along with the patch to import
switches used by perl into plperl and together it fixes the server
crash issue. Also, now, the interpreter size in both perl and plperl
module are the same thereby generating the same key on both plperl and
perl module. Thanks.Excellent. So this looks like the avenue to pursue.
As far as the question of which symbols to import goes: on my own
machines I'm seeing a lot of things like$ perl -MConfig -e 'print $Config{ccflags}'
-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64$ perl -MConfig -e 'print $Config{ccflags}'
-Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DDEBUGGING -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64I'm really quite afraid to import symbols like _LARGEFILE_SOURCE and
_FILE_OFFSET_BITS into plperl; those *will* break things if they
are different from what core Postgres is built with. Moreover,
I came across a relevant data structure in perl.h:/* These are all the compile time options that affect binary compatibility.
Other compile time options that are binary compatible are in perl.c
Both are combined for the output of perl -V
However, this string will be embedded in any shared perl library, which will
allow us add a comparison check in perlmain.c in the near future. */
#ifdef DOINIT
EXTCONST char PL_bincompat_options[] =
# ifdef DEBUG_LEAKING_SCALARS
" DEBUG_LEAKING_SCALARS"
# endif
# ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
" DEBUG_LEAKING_SCALARS_FORK_DUMP"
# endif
# ifdef FAKE_THREADS
" FAKE_THREADS"
# endif
# ifdef MULTIPLICITY
" MULTIPLICITY"
# endif
... lots more ...
Thanks for sharing this information. I too had a look into
'PL_bincompat_options' data structure in perl.h and i didn't see any
macro name starting with underscore. Based on this information, we can
now confidently say that we do not need any -D switches starting with
underscore for binary compatibility purpose.
Assuming that the Perl crew know what they're doing and this list is
complete, I notice that not one of the symbols they show as relevant
starts with an underscore. So I'm thinking that my previous semi-
joking idea of absorbing only -D switches for names that *don't*
start with an underscore was actually a good solution.
Yes, it was a good solution indeed.
If that
turns out to not be enough of a filter, we could consider looking
into perl.h to extract the set of symbols tested in building
PL_bincompat_options and then intersecting that with what we get
from Perl's ccflags. But that would be a lot more complex, so
I'd rather go with the simpler filter rule for now.
Okay, as per your suggestion, I have modified my earlier patches that
imports the -D switches used by perl into plperl accordingly i.e. it
now ignores the switches whose name starts with underscore. Please
find plperl_win_v3 and plperl_linux_v2 patches attached with this
email.
(BTW, you never did tell us exactly what defines you're getting
out of Perl's flags on the problem installation.)
I am really sorry about that. I just missed that in my earlier email.
Here are the defines used in the perl where i could reproduce the
issue,
C:\Users\ashu>perl -MConfig -e "print $Config{ccflags}"
-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -fp:precise -DWIN32
-D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DUSE_SITECUSTOMIZE
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Attachments:
plperl_win_v3.patchtext/x-patch; charset=US-ASCII; name=plperl_win_v3.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index e0bf607..f0ada1b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -518,6 +518,16 @@ sub mkvcbuild
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ foreach my $f (split(" ",$Config{ccflags}))
+ {
+ if ($f =~ /^-D/ && $f !~ /^-D_/)
+ {
+ $f =~ s/\-D//;
+ $plperl->AddDefine($f);
+ }
+ }
+
foreach my $xs ('SPI.xs', 'Util.xs')
{
(my $xsc = $xs) =~ s/\.xs/.c/;
plperl_linux_v2.patchtext/x-patch; charset=US-ASCII; name=plperl_linux_v2.patchDownload
diff --git a/config/perl.m4 b/config/perl.m4
index bed2eae..d4ec25f 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -49,6 +49,16 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
[m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
+# PGAC_CHECK_PERL_EMBED_CCFLAGS
+# -----------------------------
+AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
+[AC_REQUIRE([PGAC_PATH_PERL])
+AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/ && $f !~ /^-D_/) {print $f, " "}}'`
+AC_SUBST(perl_ccflags)dnl
+AC_MSG_RESULT([$perl_ccflags])])
+
+
# PGAC_CHECK_PERL_EMBED_LDFLAGS
# -----------------------------
# We are after Embed's ldopts, but without the subset mentioned in
diff --git a/configure b/configure
index aff72eb..ddff4ef 100755
--- a/configure
+++ b/configure
@@ -667,6 +667,7 @@ python_includespec
python_version
python_majorversion
PYTHON
+perl_ccflags
perl_embed_ldflags
perl_useshrplib
perl_privlibexp
@@ -7767,6 +7768,18 @@ documentation for details. Use --without-perl to disable building
PL/Perl." "$LINENO" 5
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Perl ccflags" >&5
+$as_echo_n "checking for Perl ccflags... " >&6; }
+perl_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {if ($f =~ /^-D/ && $f !~ /^-D_/) {print $f, " "}}'`
+
+if test -z "$perl_ccflags" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $perl_ccflags" >&5
+$as_echo "$perl_ccflags" >&6; }
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
if test "$PORTNAME" = "win32" ; then
diff --git a/configure.in b/configure.in
index 72e5b17..13c69d6 100644
--- a/configure.in
+++ b/configure.in
@@ -938,6 +938,7 @@ You might have to rebuild your Perl installation. Refer to the
documentation for details. Use --without-perl to disable building
PL/Perl.])
fi
+ PGAC_CHECK_PERL_EMBED_CCFLAGS
PGAC_CHECK_PERL_EMBED_LDFLAGS
fi
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index dc8a89a..ff1c185 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -304,6 +304,7 @@ else
endif
perl_archlibexp = @perl_archlibexp@
perl_privlibexp = @perl_privlibexp@
+perl_ccflags = @perl_ccflags@
perl_embed_ldflags = @perl_embed_ldflags@
# Miscellaneous
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index b8e3585..dce0513 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -12,7 +12,7 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
override CPPFLAGS += -Wno-comment
endif
-override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE
+override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE $(perl_ccflags)
rpathdir = $(perl_archlibexp)/CORE
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
On Fri, Jul 28, 2017 at 7:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Assuming that the Perl crew know what they're doing and this list is
complete, I notice that not one of the symbols they show as relevant
starts with an underscore. So I'm thinking that my previous semi-
joking idea of absorbing only -D switches for names that *don't*
start with an underscore was actually a good solution.
Okay, as per your suggestion, I have modified my earlier patches that
imports the -D switches used by perl into plperl accordingly i.e. it
now ignores the switches whose name starts with underscore. Please
find plperl_win_v3 and plperl_linux_v2 patches attached with this
email.
OK, thanks. I've pushed the XSUB/dTHX patch after another round of
code-reading and some minor comment improvements; we'll soon see
what the buildfarm thinks of it. In the meantime I'll work on these
two patches.
(BTW, you never did tell us exactly what defines you're getting
out of Perl's flags on the problem installation.)
I am really sorry about that. I just missed that in my earlier email.
Here are the defines used in the perl where i could reproduce the
issue,
C:\Users\ashu>perl -MConfig -e "print $Config{ccflags}"
-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -fp:precise -DWIN32
-D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DUSE_SITECUSTOMIZE
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
Uh-huh. So the issue is indeed that they're injecting PERL_IMPLICIT_SYS
via a command-line #define rather than putting it into perl's config.h,
and that results in a change in the apparent size of the PerlInterp
struct (because of IMem and friends). We'd expected as much, but it's
good to have clear confirmation.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Fri, Jul 28, 2017 at 10:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
On Fri, Jul 28, 2017 at 7:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Assuming that the Perl crew know what they're doing and this list is
complete, I notice that not one of the symbols they show as relevant
starts with an underscore. So I'm thinking that my previous semi-
joking idea of absorbing only -D switches for names that *don't*
start with an underscore was actually a good solution.Okay, as per your suggestion, I have modified my earlier patches that
imports the -D switches used by perl into plperl accordingly i.e. it
now ignores the switches whose name starts with underscore. Please
find plperl_win_v3 and plperl_linux_v2 patches attached with this
email.OK, thanks. I've pushed the XSUB/dTHX patch after another round of
code-reading and some minor comment improvements; we'll soon see
what the buildfarm thinks of it. In the meantime I'll work on these
two patches.
Sure, Thanks a lot.
(BTW, you never did tell us exactly what defines you're getting
out of Perl's flags on the problem installation.)I am really sorry about that. I just missed that in my earlier email.
Here are the defines used in the perl where i could reproduce the
issue,C:\Users\ashu>perl -MConfig -e "print $Config{ccflags}"
-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -fp:precise -DWIN32
-D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DUSE_SITECUSTOMIZE
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYSUh-huh. So the issue is indeed that they're injecting PERL_IMPLICIT_SYS
via a command-line #define rather than putting it into perl's config.h,
and that results in a change in the apparent size of the PerlInterp
struct (because of IMem and friends).
Yes, That's right. We would have seen different result if the
PERL_IMPLICIT_SYS would not have been defined globally.
We'd expected as much, but it's
good to have clear confirmation.
That's right. It is always good to have a clear confirmation. Thanks.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
On Fri, Jul 28, 2017 at 10:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Uh-huh. So the issue is indeed that they're injecting PERL_IMPLICIT_SYS
via a command-line #define rather than putting it into perl's config.h,
and that results in a change in the apparent size of the PerlInterp
struct (because of IMem and friends).
Yes, That's right. We would have seen different result if the
PERL_IMPLICIT_SYS would not have been defined globally.
I've pushed the changes to the build scripts now. I had to revise the
Mkvcbuild.pm part a bit, because you'd forgotten to propagate the extra
defines into hstore_plperl. So that code is untested; please confirm
that HEAD works in your problem environment now.
I notice that Mkvcbuild.pm is artificially injecting a define for
PLPERL_HAVE_UID_GID. I strongly suspect that that was a hack meant
to work around the lack of this mechanism, and that we could now
get rid of it or clean it up. But there's no evidence in the commit
log about the reason for it --- it seems to go back to the original
addition of MSVC support. Anybody remember?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sat, Jul 29, 2017 at 12:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
On Fri, Jul 28, 2017 at 10:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Uh-huh. So the issue is indeed that they're injecting PERL_IMPLICIT_SYS
via a command-line #define rather than putting it into perl's config.h,
and that results in a change in the apparent size of the PerlInterp
struct (because of IMem and friends).Yes, That's right. We would have seen different result if the
PERL_IMPLICIT_SYS would not have been defined globally.I've pushed the changes to the build scripts now. I had to revise the
Mkvcbuild.pm part a bit, because you'd forgotten to propagate the extra
defines into hstore_plperl.
Thanks for that.
So that code is untested; please confirm
that HEAD works in your problem environment now.
I quickly ran the some basic test-cases on my Windows machine (machine
where i have been regenerating the issue) and they are all passing.
Also, all the automated test-cases for contrib module hstore_plperl
are passing.
I notice that Mkvcbuild.pm is artificially injecting a define for
PLPERL_HAVE_UID_GID. I strongly suspect that that was a hack meant
to work around the lack of this mechanism, and that we could now
get rid of it or clean it up. But there's no evidence in the commit
log about the reason for it --- it seems to go back to the original
addition of MSVC support. Anybody remember?regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Christoph Berg <myon@debian.org> writes:
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
/messages/by-id/20130515064201.GC704@msgid.df7cb.de
https://buildd.debian.org/status/fetch.php?pkg=postgresql-10&arch=kfreebsd-amd64&ver=10~beta2-1&stamp=1499947011&raw=0
So it'd be interesting to know if it's any better with HEAD ...
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Ashutosh Sharma <ashu.coek88@gmail.com> writes:
I quickly ran the some basic test-cases on my Windows machine (machine
where i have been regenerating the issue) and they are all passing.
Also, all the automated test-cases for contrib module hstore_plperl
are passing.
Cool, thanks. I hope people will set up some buildfarm machines with
the formerly-broken configurations.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Re: Tom Lane 2017-07-28 <3254.1501276475@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
/messages/by-id/20130515064201.GC704@msgid.df7cb.de
https://buildd.debian.org/status/fetch.php?pkg=postgresql-10&arch=kfreebsd-amd64&ver=10~beta2-1&stamp=1499947011&raw=0So it'd be interesting to know if it's any better with HEAD ...
Unfortunately not:
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost
The only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
... which is unchanged from the beta2 output.
Christoph
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Christoph Berg <myon@debian.org> writes:
Re: Tom Lane 2017-07-28 <3254.1501276475@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
So it'd be interesting to know if it's any better with HEAD ...
Unfortunately not:
The only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
... which is unchanged from the beta2 output.
Well, that's quite interesting, because it implies that this is indeed
the same type of problem. I wonder why the patch didn't fix it?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Hi Christoph,
On Mon, Jul 31, 2017 at 2:44 AM, Christoph Berg <myon@debian.org> wrote:
Re: Tom Lane 2017-07-28 <3254.1501276475@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
/messages/by-id/20130515064201.GC704@msgid.df7cb.de
https://buildd.debian.org/status/fetch.php?pkg=postgresql-10&arch=kfreebsd-amd64&ver=10~beta2-1&stamp=1499947011&raw=0So it'd be interesting to know if it's any better with HEAD ...
Unfortunately not:
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lostThe only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
... which is unchanged from the beta2 output.
I am not able to reproduce this issue on my Windows or Linux box. Have
you deleted Util.c and SPI.c files before starting with the build? The
point is, these files are generated during build time and if they
already exist then i think. they are not re generated. I would suggest
to delete both the .c files and rebuild your source and then give a
try.
Here are the results i got on Windows and Linux respectively on HEAD,
On Windows:
C:\Users\ashu\git-clone-postgresql\postgresql\src\tools\msvc>vcregress.bat
PLCHECK
============================================================
Checking plperl
(using postmaster on localhost, default port)
============== dropping database "pl_regression" ==============
NOTICE: database "pl_regression" does not exist, skipping
DROP DATABASE
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
CREATE EXTENSION
============== installing plperlu ==============
CREATE EXTENSION
============== running regression test queries ==============
test plperl ... ok
test plperl_lc ... ok
test plperl_trigger ... ok
test plperl_shared ... ok
test plperl_elog ... ok
test plperl_util ... ok
test plperl_init ... ok
test plperlu ... ok
test plperl_array ... ok
test plperl_plperlu ... ok
======================
All 10 tests passed.
======================
On Linux:
LD_LIBRARY_PATH="/home/ashu/git-clone-postgresql/postgresql/tmp_install/home/ashu/git-clone-postgresql/postgresql/TMP/postgres/lib"
../../../src/test/regress/pg_regress --temp-instance=./tmp_check
--inputdir=. --bindir= --dbname=pl_regression
--load-extension=plperl --load-extension=plperlu plperl plperl_lc
plperl_trigger plperl_shared plperl_elog plperl_util plperl_init
plperlu plperl_array
============== creating temporary instance ==============
============== initializing database system ==============
============== starting postmaster ==============
running on port 50848 with PID 18140
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
CREATE EXTENSION
============== installing plperlu ==============
CREATE EXTENSION
============== running regression test queries ==============
test plperl ... ok
test plperl_lc ... ok
test plperl_trigger ... ok
test plperl_shared ... ok
test plperl_elog ... ok
test plperl_util ... ok
test plperl_init ... ok
test plperlu ... ok
test plperl_array ... ok
============== shutting down postmaster ==============
============== removing temporary instance ==============
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Hi Christoph,
On Mon, Jul 31, 2017 at 9:18 AM, Ashutosh Sharma <ashu.coek88@gmail.com> wrote:
Hi Christoph,
On Mon, Jul 31, 2017 at 2:44 AM, Christoph Berg <myon@debian.org> wrote:
Re: Tom Lane 2017-07-28 <3254.1501276475@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The plperl segfault on Debian's kfreebsd port I reported back in 2013
is also still present:
/messages/by-id/20130515064201.GC704@msgid.df7cb.de
https://buildd.debian.org/status/fetch.php?pkg=postgresql-10&arch=kfreebsd-amd64&ver=10~beta2-1&stamp=1499947011&raw=0So it'd be interesting to know if it's any better with HEAD ...
Unfortunately not:
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lostThe only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
... which is unchanged from the beta2 output.
It seems like you are observing this crash on kFreeBSD OS. Well, me or
any of my colleague is not having this OS hence, i can't comment on
that. But, we do have Ubuntu OS (another Debian based OS) and I am not
seeing any server crash here as well,
edb@ubuntu:~/PGsources/postgresql/src/pl/plperl$ make check
make -C ../../../src/test/regress pg_regress
.....
/bin/mkdir -p '/home/edb/PGsources/postgresql'/tmp_install/log
make -C '../../..'
DESTDIR='/home/edb/PGsources/postgresql'/tmp_install install
'/home/edb/PGsources/postgresql'/tmp_install/log/install.log 2>&1
PATH="/home/edb/PGsources/postgresql/tmp_install/home/edb/PGsources/postgresql/inst/bin:$PATH"
LD_LIBRARY_PATH="/home/edb/PGsources/postgresql/tmp_install/home/edb/PGsources/postgresql/inst/lib:$LD_LIBRARY_PATH"
../../../src/test/regress/pg_regress --temp-instance=./tmp_check
--inputdir=. --bindir= --dbname=pl_regression
--load-extension=plperl --load-extension=plperlu plperl plperl_lc
plperl_trigger plperl_shared plperl_elog plperl_util plperl_init
plperlu plperl_array plperl_plperlu
============== creating temporary instance ==============
============== initializing database system ==============
============== starting postmaster ==============
running on port 50848 with PID 43441
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
CREATE EXTENSION
============== installing plperlu ==============
CREATE EXTENSION
============== running regression test queries ==============
test plperl ... ok
test plperl_lc ... ok
test plperl_trigger ... ok
test plperl_shared ... ok
test plperl_elog ... ok
test plperl_util ... ok
test plperl_init ... ok
test plperlu ... ok
test plperl_array ... ok
test plperl_plperlu ... ok
============== shutting down postmaster ==============
============== removing temporary instance ==============
As i mentioned in my earlier email, could you please delete the Utilc.
and SPI.c files from src/pl/plperl directory, rebuild the source code
and then let us know the results. Thanks.
I am not able to reproduce this issue on my Windows or Linux box. Have
you deleted Util.c and SPI.c files before starting with the build? The
point is, these files are generated during build time and if they
already exist then i think. they are not re generated. I would suggest
to delete both the .c files and rebuild your source and then give a
try.Here are the results i got on Windows and Linux respectively on HEAD,
On Windows:
C:\Users\ashu\git-clone-postgresql\postgresql\src\tools\msvc>vcregress.bat
PLCHECK
============================================================
Checking plperl
(using postmaster on localhost, default port)
============== dropping database "pl_regression" ==============
NOTICE: database "pl_regression" does not exist, skipping
DROP DATABASE
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
CREATE EXTENSION
============== installing plperlu ==============
CREATE EXTENSION
============== running regression test queries ==============
test plperl ... ok
test plperl_lc ... ok
test plperl_trigger ... ok
test plperl_shared ... ok
test plperl_elog ... ok
test plperl_util ... ok
test plperl_init ... ok
test plperlu ... ok
test plperl_array ... ok
test plperl_plperlu ... ok======================
All 10 tests passed.
======================On Linux:
LD_LIBRARY_PATH="/home/ashu/git-clone-postgresql/postgresql/tmp_install/home/ashu/git-clone-postgresql/postgresql/TMP/postgres/lib"
../../../src/test/regress/pg_regress --temp-instance=./tmp_check
--inputdir=. --bindir= --dbname=pl_regression
--load-extension=plperl --load-extension=plperlu plperl plperl_lc
plperl_trigger plperl_shared plperl_elog plperl_util plperl_init
plperlu plperl_array
============== creating temporary instance ==============
============== initializing database system ==============
============== starting postmaster ==============
running on port 50848 with PID 18140
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
CREATE EXTENSION
============== installing plperlu ==============
CREATE EXTENSION
============== running regression test queries ==============
test plperl ... ok
test plperl_lc ... ok
test plperl_trigger ... ok
test plperl_shared ... ok
test plperl_elog ... ok
test plperl_util ... ok
test plperl_init ... ok
test plperlu ... ok
test plperl_array ... ok
============== shutting down postmaster ==============
============== removing temporary instance ==============--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Re: Ashutosh Sharma 2017-07-31 <CAE9k0PnzYxyKHuwJonUEDt2xunPUc8VUVPWsd0BScRd3u+j8_A@mail.gmail.com>
The only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
... which is unchanged from the beta2 output.I am not able to reproduce this issue on my Windows or Linux box. Have
you deleted Util.c and SPI.c files before starting with the build?
That was from a git checkout which didn't contain the files.
Retrying anyway:
[127]: 10:28 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ make clean rm -f plperl.so libplperl.a libplperl.pc rm -f SPI.c Util.c plperl.o SPI.o Util.o perlchunks.h plperl_opmask.h rm -rf results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
rm -f plperl.so libplperl.a libplperl.pc
rm -f SPI.c Util.c plperl.o SPI.o Util.o perlchunks.h plperl_opmask.h
rm -rf results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
[0]: 10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ make check make -C ../../../src/test/regress pg_regress make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird betreten make -C ../../../src/port all make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird betreten make -C ../backend submake-errcodes make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun. make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird verlassen make -C ../../../src/common all make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird betreten make -C ../backend submake-errcodes make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun. make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird verlassen make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird verlassen rm -rf '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install /bin/mkdir -p '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log make -C '../../..' DESTDIR='/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install install >'/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log/install.log 2>&1 PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/bin:$PATH" LD_LIBRARY_PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/lib" ../../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir= --dbname=pl_regression --load-extension=plperl --load-extension=plperlu plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array plperl_plperlu ============== creating temporary instance ============== ============== initializing database system ============== ============== starting postmaster ============== running on port 50848 with PID 17713 ============== creating database "pl_regression" ============== CREATE DATABASE ALTER DATABASE ============== installing plperl ============== server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. connection to server was lost command failed: "psql" -X -c "CREATE EXTENSION IF NOT EXISTS \"plperl\"" "pl_regression" GNUmakefile:108: die Regel für Ziel „check“ scheiterte make: *** [check] Fehler 2
'/usr/bin/perl' ./text2macro.pl --strip='^(\#.*|\s*)$' plc_perlboot.pl plc_trusted.pl > perlchunks.h
'/usr/bin/perl' plperl_opmask.pl plperl_opmask.h
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../../src/include -D_GNU_SOURCE -I/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -c -o plperl.o plperl.c
'/usr/bin/perl' /usr/share/perl/5.26/ExtUtils/xsubpp -typemap /usr/share/perl/5.26/ExtUtils/typemap SPI.xs >SPI.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../../src/include -D_GNU_SOURCE -I/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -c -o SPI.o SPI.c
'/usr/bin/perl' /usr/share/perl/5.26/ExtUtils/xsubpp -typemap /usr/share/perl/5.26/ExtUtils/typemap Util.xs >Util.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../../src/include -D_GNU_SOURCE -I/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -c -o Util.o Util.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o plperl.so plperl.o SPI.o Util.o -L../../../src/port -L../../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE',--enable-new-dtags -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lc -lcrypt
[0]: 10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ make check make -C ../../../src/test/regress pg_regress make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird betreten make -C ../../../src/port all make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird betreten make -C ../backend submake-errcodes make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun. make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird verlassen make -C ../../../src/common all make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird betreten make -C ../backend submake-errcodes make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun. make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen make[2]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird verlassen make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird verlassen rm -rf '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install /bin/mkdir -p '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log make -C '../../..' DESTDIR='/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install install >'/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log/install.log 2>&1 PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/bin:$PATH" LD_LIBRARY_PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/lib" ../../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir= --dbname=pl_regression --load-extension=plperl --load-extension=plperlu plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array plperl_plperlu ============== creating temporary instance ============== ============== initializing database system ============== ============== starting postmaster ============== running on port 50848 with PID 17713 ============== creating database "pl_regression" ============== CREATE DATABASE ALTER DATABASE ============== installing plperl ============== server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. connection to server was lost command failed: "psql" -X -c "CREATE EXTENSION IF NOT EXISTS \"plperl\"" "pl_regression" GNUmakefile:108: die Regel für Ziel „check“ scheiterte make: *** [check] Fehler 2
make -C ../../../src/test/regress pg_regress
make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird betreten
make -C ../../../src/port all
make[2]10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ cat log/postmaster.log 2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848" 2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST 2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections 2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all 2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB 2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait 2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080) 2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request 2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions 2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1 2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down 2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate 2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB 2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird betreten
make -C ../backend submake-errcodes
make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten
make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun.
make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen
make[2]10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ cat log/postmaster.log 2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848" 2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST 2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections 2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all 2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB 2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait 2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080) 2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request 2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions 2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1 2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down 2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate 2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB 2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/port“ wird verlassen
make -C ../../../src/common all
make[2]10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ cat log/postmaster.log 2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848" 2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST 2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections 2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all 2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB 2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait 2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080) 2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request 2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions 2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1 2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down 2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate 2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB 2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird betreten
make -C ../backend submake-errcodes
make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird betreten
make[3]: Für das Ziel „submake-errcodes“ ist nichts zu tun.
make[3]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/backend“ wird verlassen
make[2]10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ cat log/postmaster.log 2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848" 2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST 2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections 2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all 2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB 2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait 2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080) 2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request 2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions 2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1 2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down 2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate 2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB 2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/common“ wird verlassen
make[1]: Verzeichnis „/home/myon/postgresql-10/postgresql-10-10~beta2/src/test/regress“ wird verlassen
rm -rf '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install
/bin/mkdir -p '/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log
make -C '../../..' DESTDIR='/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install install >'/home/myon/postgresql-10/postgresql-10-10~beta2'/tmp_install/log/install.log 2>&1
PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/bin:$PATH" LD_LIBRARY_PATH="/home/myon/postgresql-10/postgresql-10-10~beta2/tmp_install/usr/local/pgsql/lib" ../../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir= --dbname=pl_regression --load-extension=plperl --load-extension=plperlu plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array plperl_plperlu
============== creating temporary instance ==============
============== initializing database system ==============
============== starting postmaster ==============
running on port 50848 with PID 17713
============== creating database "pl_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing plperl ==============
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost
command failed: "psql" -X -c "CREATE EXTENSION IF NOT EXISTS \"plperl\"" "pl_regression"
GNUmakefile:108: die Regel für Ziel „check“ scheiterte
make: *** [check] Fehler 2
[2]: 10:29 myon@experimental_k-a-dchroot.falla:~/po/po/src/pl/plperl $ cat log/postmaster.log 2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848" 2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST 2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections 2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all 2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB 2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait 2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080) 2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request 2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions 2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1 2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down 2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate 2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB 2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down
2017-07-31 10:29:54.995 CEST [17713] LOG: listening on Unix socket "/tmp/pg_regress-JaWXuT/.s.PGSQL.50848"
2017-07-31 10:29:55.015 CEST [17716] LOG: database system was shut down at 2017-07-31 10:29:54 CEST
2017-07-31 10:29:55.023 CEST [17713] LOG: database system is ready to accept connections
2017-07-31 10:29:56.068 CEST [17717] LOG: checkpoint starting: immediate force wait flush-all
2017-07-31 10:29:56.071 CEST [17717] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=1 kB, estimate=1 kB
2017-07-31 10:29:56.303 CEST [17717] LOG: checkpoint starting: immediate force wait
2017-07-31 10:29:56.305 CEST [17717] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=0.001 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=1 kB
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
2017-07-31 10:29:56.478 CEST [17713] LOG: received fast shutdown request
2017-07-31 10:29:56.478 CEST [17713] LOG: aborting any active transactions
2017-07-31 10:29:56.480 CEST [17713] LOG: worker process: logical replication launcher (PID 17722) exited with exit code 1
2017-07-31 10:29:56.481 CEST [17717] LOG: shutting down
2017-07-31 10:29:56.481 CEST [17717] LOG: checkpoint starting: shutdown immediate
2017-07-31 10:29:56.484 CEST [17717] LOG: checkpoint complete: wrote 19 buffers (0.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.000 s, total=0.003 s; sync files=0, longest=0.000 s, average=0.000 s; distance=47 kB, estimate=47 kB
2017-07-31 10:29:56.494 CEST [17713] LOG: database system is shut down
Christoph
Attachments:
SPI.ctext/x-csrc; charset=us-asciiDownload
/*
* This file was generated automatically by ExtUtils::ParseXS version 3.34 from the
* contents of SPI.xs. Do not edit this file, edit SPI.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "SPI.xs"
/**********************************************************************
* PostgreSQL::InServer::SPI
*
* SPI interface for plperl.
*
* src/pl/plperl/SPI.xs
*
**********************************************************************/
/* this must be first: */
#include "postgres.h"
#include "mb/pg_wchar.h" /* for GetDatabaseEncoding */
/* Defined by Perl */
#undef _
/* perl stuff */
#include "plperl.h"
#include "plperl_helpers.h"
/*
* Interface routine to catch ereports and punt them to Perl
*/
static void
do_plperl_return_next(SV *sv)
{
MemoryContext oldcontext = CurrentMemoryContext;
PG_TRY();
{
plperl_return_next(sv);
}
PG_CATCH();
{
ErrorData *edata;
/* Must reset elog.c's state */
MemoryContextSwitchTo(oldcontext);
edata = CopyErrorData();
FlushErrorState();
/* Punt the error to Perl */
croak_cstr(edata->message);
}
PG_END_TRY();
}
#line 60 "SPI.c"
#ifndef PERL_UNUSED_VAR
# define PERL_UNUSED_VAR(var) if (0) var = var
#endif
#ifndef dVAR
# define dVAR dNOOP
#endif
/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
# define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
# define PERL_DECIMAL_VERSION \
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
# define PERL_VERSION_GE(r,v,s) \
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
# define PERL_VERSION_LE(r,v,s) \
(PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif
/* XS_INTERNAL is the explicit static-linkage variant of the default
* XS macro.
*
* XS_EXTERNAL is the same as XS_INTERNAL except it does not include
* "STATIC", ie. it exports XSUB symbols. You probably don't want that
* for anything but the BOOT XSUB.
*
* See XSUB.h in core!
*/
/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
# undef XS_EXTERNAL
# undef XS_INTERNAL
# if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
# define XS_INTERNAL(name) STATIC XSPROTO(name)
# endif
# if defined(__SYMBIAN32__)
# define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
# define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
# endif
# ifndef XS_EXTERNAL
# if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
# else
# ifdef __cplusplus
# define XS_EXTERNAL(name) extern "C" XSPROTO(name)
# define XS_INTERNAL(name) static XSPROTO(name)
# else
# define XS_EXTERNAL(name) XSPROTO(name)
# define XS_INTERNAL(name) STATIC XSPROTO(name)
# endif
# endif
# endif
#endif
/* perl >= 5.10.0 && perl <= 5.15.1 */
/* The XS_EXTERNAL macro is used for functions that must not be static
* like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
* macro defined, the best we can do is assume XS is the same.
* Dito for XS_INTERNAL.
*/
#ifndef XS_EXTERNAL
# define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
# define XS_INTERNAL(name) XS(name)
#endif
/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
* internal macro that we're free to redefine for varying linkage due
* to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
* XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
*/
#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
# define XS_EUPXS(name) XS_EXTERNAL(name)
#else
/* default to internal */
# define XS_EUPXS(name) XS_INTERNAL(name)
#endif
#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
const GV *const gv = CvGV(cv);
PERL_ARGS_ASSERT_CROAK_XS_USAGE;
if (gv) {
const char *const gvname = GvNAME(gv);
const HV *const stash = GvSTASH(gv);
const char *const hvname = stash ? HvNAME(stash) : NULL;
if (hvname)
Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
else
Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
} else {
/* Pants. I don't think that it should be possible to get here. */
Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
}
}
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define croak_xs_usage S_croak_xs_usage
#endif
/* NOTE: the prototype of newXSproto() is different in versions of perls,
* so we define a portable version of newXSproto()
*/
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */
#if PERL_VERSION_LE(5, 21, 5)
# define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
# define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif
#line 204 "SPI.c"
XS_EUPXS(XS__spi_exec_query); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_exec_query)
{
dVAR; dXSARGS;
if (items < 1)
croak_xs_usage(cv, "sv, ...");
{
SV* sv = ST(0)
;
#line 59 "SPI.xs"
HV *ret_hash;
int limit = 0;
char *query;
#line 219 "SPI.c"
SV * RETVAL;
#line 63 "SPI.xs"
if (items > 2)
croak("Usage: spi_exec_query(query, limit) "
"or spi_exec_query(query)");
if (items == 2)
limit = SvIV(ST(1));
query = sv2cstr(sv);
ret_hash = plperl_spi_exec(query, limit);
pfree(query);
RETVAL = newRV_noinc((SV*) ret_hash);
#line 231 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__return_next); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__return_next)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "rv");
{
SV * rv = ST(0)
;
#line 79 "SPI.xs"
do_plperl_return_next(rv);
#line 250 "SPI.c"
}
XSRETURN_EMPTY;
}
XS_EUPXS(XS__spi_query); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_query)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
SV * RETVAL;
#line 85 "SPI.xs"
char* query = sv2cstr(sv);
RETVAL = plperl_spi_query(query);
pfree(query);
#line 270 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__spi_fetchrow); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_fetchrow)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV* sv = ST(0)
;
SV * RETVAL;
#line 95 "SPI.xs"
char* cursor = sv2cstr(sv);
RETVAL = plperl_spi_fetchrow(cursor);
pfree(cursor);
#line 292 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__spi_prepare); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_prepare)
{
dVAR; dXSARGS;
if (items < 1)
croak_xs_usage(cv, "sv, ...");
{
SV* sv = ST(0)
;
SV * RETVAL;
#line 105 "SPI.xs"
int i;
SV** argv;
char* query = sv2cstr(sv);
if (items < 1)
Perl_croak(aTHX_ "Usage: spi_prepare(query, ...)");
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
for ( i = 1; i < items; i++)
argv[i - 1] = ST(i);
RETVAL = plperl_spi_prepare(query, items - 1, argv);
pfree( argv);
pfree(query);
#line 322 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__spi_exec_prepared); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_exec_prepared)
{
dVAR; dXSARGS;
if (items < 1)
croak_xs_usage(cv, "sv, ...");
{
SV* sv = ST(0)
;
#line 123 "SPI.xs"
HV *ret_hash;
#line 341 "SPI.c"
SV * RETVAL;
#line 125 "SPI.xs"
HV *attr = NULL;
int i, offset = 1, argc;
SV ** argv;
char *query = sv2cstr(sv);
if ( items < 1)
Perl_croak(aTHX_ "Usage: spi_exec_prepared(query, [\\%%attr,] "
"[\\@bind_values])");
if ( items > 1 && SvROK( ST( 1)) && SvTYPE( SvRV( ST( 1))) == SVt_PVHV)
{
attr = ( HV*) SvRV(ST(1));
offset++;
}
argc = items - offset;
argv = ( SV**) palloc( argc * sizeof(SV*));
for ( i = 0; offset < items; offset++, i++)
argv[i] = ST(offset);
ret_hash = plperl_spi_exec_prepared(query, attr, argc, argv);
RETVAL = newRV_noinc((SV*)ret_hash);
pfree( argv);
pfree(query);
#line 364 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__spi_query_prepared); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_query_prepared)
{
dVAR; dXSARGS;
if (items < 1)
croak_xs_usage(cv, "sv, ...");
{
SV * sv = ST(0)
;
SV * RETVAL;
#line 152 "SPI.xs"
int i;
SV ** argv;
char *query = sv2cstr(sv);
if ( items < 1)
Perl_croak(aTHX_ "Usage: spi_query_prepared(query, "
"[\\@bind_values])");
argv = ( SV**) palloc(( items - 1) * sizeof(SV*));
for ( i = 1; i < items; i++)
argv[i - 1] = ST(i);
RETVAL = plperl_spi_query_prepared(query, items - 1, argv);
pfree( argv);
pfree(query);
#line 395 "SPI.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__spi_freeplan); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_freeplan)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
#line 171 "SPI.xs"
char *query = sv2cstr(sv);
plperl_spi_freeplan(query);
pfree(query);
#line 416 "SPI.c"
}
XSRETURN_EMPTY;
}
XS_EUPXS(XS__spi_cursor_close); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__spi_cursor_close)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
#line 179 "SPI.xs"
char *cursor = sv2cstr(sv);
plperl_spi_cursor_close(cursor);
pfree(cursor);
#line 435 "SPI.c"
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_PostgreSQL__InServer__SPI); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_PostgreSQL__InServer__SPI)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
dVAR; dXSBOOTARGSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
char* file = __FILE__;
#else
const char* file = __FILE__;
#endif
PERL_UNUSED_VAR(file);
PERL_UNUSED_VAR(cv); /* -W */
PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5) && defined(XS_APIVERSION_BOOTCHECK)
XS_APIVERSION_BOOTCHECK;
#endif
(void)newXSproto_portable("spi_exec_query", XS__spi_exec_query, file, "$;@");
(void)newXSproto_portable("return_next", XS__return_next, file, "$");
(void)newXSproto_portable("spi_query", XS__spi_query, file, "$");
(void)newXSproto_portable("spi_fetchrow", XS__spi_fetchrow, file, "$");
(void)newXSproto_portable("spi_prepare", XS__spi_prepare, file, "$;@");
(void)newXSproto_portable("spi_exec_prepared", XS__spi_exec_prepared, file, "$;@");
(void)newXSproto_portable("spi_query_prepared", XS__spi_query_prepared, file, "$;@");
(void)newXSproto_portable("spi_freeplan", XS__spi_freeplan, file, "$");
(void)newXSproto_portable("spi_cursor_close", XS__spi_cursor_close, file, "$");
/* Initialisation Section */
#line 185 "SPI.xs"
items = 0; /* avoid 'unused variable' warning */
#line 480 "SPI.c"
/* End of Initialisation Section */
#if PERL_VERSION_LE(5, 21, 5)
# if PERL_VERSION_GE(5, 9, 0)
if (PL_unitcheckav)
call_list(PL_scopestack_ix, PL_unitcheckav);
# endif
XSRETURN_YES;
#else
Perl_xs_boot_epilog(aTHX_ ax);
#endif
}
Util.ctext/x-csrc; charset=us-asciiDownload
/*
* This file was generated automatically by ExtUtils::ParseXS version 3.34 from the
* contents of Util.xs. Do not edit this file, edit Util.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "Util.xs"
/**********************************************************************
* PostgreSQL::InServer::Util
*
* src/pl/plperl/Util.xs
*
* Defines plperl interfaces for general-purpose utilities.
* This module is bootstrapped as soon as an interpreter is initialized.
* Currently doesn't define a PACKAGE= so all subs are in main:: to avoid
* the need for explicit importing.
*
**********************************************************************/
/* this must be first: */
#include "postgres.h"
#include "fmgr.h"
#include "utils/builtins.h"
#include "utils/bytea.h" /* for byteain & byteaout */
#include "mb/pg_wchar.h" /* for GetDatabaseEncoding */
/* Defined by Perl */
#undef _
/* perl stuff */
#include "plperl.h"
#include "plperl_helpers.h"
/*
* Implementation of plperl's elog() function
*
* If the error level is less than ERROR, we'll just emit the message and
* return. When it is ERROR, elog() will longjmp, which we catch and
* turn into a Perl croak(). Note we are assuming that elog() can't have
* any internal failures that are so bad as to require a transaction abort.
*
* This is out-of-line to suppress "might be clobbered by longjmp" warnings.
*/
static void
do_util_elog(int level, SV *msg)
{
MemoryContext oldcontext = CurrentMemoryContext;
char * volatile cmsg = NULL;
PG_TRY();
{
cmsg = sv2cstr(msg);
elog(level, "%s", cmsg);
pfree(cmsg);
}
PG_CATCH();
{
ErrorData *edata;
/* Must reset elog.c's state */
MemoryContextSwitchTo(oldcontext);
edata = CopyErrorData();
FlushErrorState();
if (cmsg)
pfree(cmsg);
/* Punt the error to Perl */
croak_cstr(edata->message);
}
PG_END_TRY();
}
static text *
sv2text(SV *sv)
{
char *str = sv2cstr(sv);
text *text;
text = cstring_to_text(str);
pfree(str);
return text;
}
#line 87 "Util.c"
#ifndef PERL_UNUSED_VAR
# define PERL_UNUSED_VAR(var) if (0) var = var
#endif
#ifndef dVAR
# define dVAR dNOOP
#endif
/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
# define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
# define PERL_DECIMAL_VERSION \
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
# define PERL_VERSION_GE(r,v,s) \
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
# define PERL_VERSION_LE(r,v,s) \
(PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif
/* XS_INTERNAL is the explicit static-linkage variant of the default
* XS macro.
*
* XS_EXTERNAL is the same as XS_INTERNAL except it does not include
* "STATIC", ie. it exports XSUB symbols. You probably don't want that
* for anything but the BOOT XSUB.
*
* See XSUB.h in core!
*/
/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
# undef XS_EXTERNAL
# undef XS_INTERNAL
# if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
# define XS_INTERNAL(name) STATIC XSPROTO(name)
# endif
# if defined(__SYMBIAN32__)
# define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
# define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
# endif
# ifndef XS_EXTERNAL
# if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
# else
# ifdef __cplusplus
# define XS_EXTERNAL(name) extern "C" XSPROTO(name)
# define XS_INTERNAL(name) static XSPROTO(name)
# else
# define XS_EXTERNAL(name) XSPROTO(name)
# define XS_INTERNAL(name) STATIC XSPROTO(name)
# endif
# endif
# endif
#endif
/* perl >= 5.10.0 && perl <= 5.15.1 */
/* The XS_EXTERNAL macro is used for functions that must not be static
* like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
* macro defined, the best we can do is assume XS is the same.
* Dito for XS_INTERNAL.
*/
#ifndef XS_EXTERNAL
# define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
# define XS_INTERNAL(name) XS(name)
#endif
/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
* internal macro that we're free to redefine for varying linkage due
* to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
* XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
*/
#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
# define XS_EUPXS(name) XS_EXTERNAL(name)
#else
/* default to internal */
# define XS_EUPXS(name) XS_INTERNAL(name)
#endif
#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
const GV *const gv = CvGV(cv);
PERL_ARGS_ASSERT_CROAK_XS_USAGE;
if (gv) {
const char *const gvname = GvNAME(gv);
const HV *const stash = GvSTASH(gv);
const char *const hvname = stash ? HvNAME(stash) : NULL;
if (hvname)
Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
else
Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
} else {
/* Pants. I don't think that it should be possible to get here. */
Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
}
}
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define croak_xs_usage S_croak_xs_usage
#endif
/* NOTE: the prototype of newXSproto() is different in versions of perls,
* so we define a portable version of newXSproto()
*/
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */
#if PERL_VERSION_LE(5, 21, 5)
# define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
# define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif
#line 231 "Util.c"
XS_EUPXS(XS___aliased_constants); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS___aliased_constants)
{
dVAR; dXSARGS;
dXSI32;
if (items != 0)
croak_xs_usage(cv, "");
{
int RETVAL;
dXSTARG;
#line 93 "Util.xs"
/* uses the ALIAS value as the return value */
RETVAL = ix;
#line 246 "Util.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS_EUPXS(XS__elog); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__elog)
{
dVAR; dXSARGS;
if (items != 2)
croak_xs_usage(cv, "level, msg");
{
int level = (int)SvIV(ST(0))
;
SV * msg = ST(1)
;
#line 104 "Util.xs"
if (level > ERROR) /* no PANIC allowed thanks */
level = ERROR;
if (level < DEBUG5)
level = DEBUG5;
do_util_elog(level, msg);
#line 270 "Util.c"
}
XSRETURN_EMPTY;
}
XS_EUPXS(XS__quote_literal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__quote_literal)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
SV * RETVAL;
#line 114 "Util.xs"
if (!sv || !SvOK(sv)) {
RETVAL = &PL_sv_undef;
}
else {
text *arg = sv2text(sv);
text *quoted = DatumGetTextPP(DirectFunctionCall1(quote_literal, PointerGetDatum(arg)));
char *str;
pfree(arg);
str = text_to_cstring(quoted);
RETVAL = cstr2sv(str);
pfree(str);
}
#line 300 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__quote_nullable); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__quote_nullable)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
SV * RETVAL;
#line 134 "Util.xs"
if (!sv || !SvOK(sv))
{
RETVAL = cstr2sv("NULL");
}
else
{
text *arg = sv2text(sv);
text *quoted = DatumGetTextPP(DirectFunctionCall1(quote_nullable, PointerGetDatum(arg)));
char *str;
pfree(arg);
str = text_to_cstring(quoted);
RETVAL = cstr2sv(str);
pfree(str);
}
#line 334 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__quote_ident); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__quote_ident)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
#line 156 "Util.xs"
text *arg;
text *quoted;
char *str;
#line 355 "Util.c"
SV * RETVAL;
#line 160 "Util.xs"
arg = sv2text(sv);
quoted = DatumGetTextPP(DirectFunctionCall1(quote_ident, PointerGetDatum(arg)));
pfree(arg);
str = text_to_cstring(quoted);
RETVAL = cstr2sv(str);
pfree(str);
#line 365 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__decode_bytea); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__decode_bytea)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
#line 174 "Util.xs"
char *arg;
text *ret;
#line 385 "Util.c"
SV * RETVAL;
#line 177 "Util.xs"
arg = SvPVbyte_nolen(sv);
ret = DatumGetTextPP(DirectFunctionCall1(byteain, PointerGetDatum(arg)));
/* not cstr2sv because this is raw bytes not utf8'able */
RETVAL = newSVpvn(VARDATA_ANY(ret), VARSIZE_ANY_EXHDR(ret));
#line 392 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__encode_bytea); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__encode_bytea)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
#line 188 "Util.xs"
text *arg;
char *ret;
STRLEN len;
#line 413 "Util.c"
SV * RETVAL;
#line 192 "Util.xs"
/* not sv2text because this is raw bytes not utf8'able */
ret = SvPVbyte(sv, len);
arg = cstring_to_text_with_len(ret, len);
ret = DatumGetCString(DirectFunctionCall1(byteaout, PointerGetDatum(arg)));
RETVAL = cstr2sv(ret);
#line 421 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__looks_like_number); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__looks_like_number)
{
dVAR; dXSARGS;
if (items != 1)
croak_xs_usage(cv, "sv");
{
SV * sv = ST(0)
;
SV * RETVAL;
#line 204 "Util.xs"
if (!SvOK(sv))
RETVAL = &PL_sv_undef;
else if ( looks_like_number(sv) )
RETVAL = &PL_sv_yes;
else
RETVAL = &PL_sv_no;
#line 446 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
XS_EUPXS(XS__encode_typed_literal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS__encode_typed_literal)
{
dVAR; dXSARGS;
if (items != 2)
croak_xs_usage(cv, "sv, typname");
{
SV * sv = ST(0)
;
char * typname = (char *)SvPV_nolen(ST(1))
;
#line 218 "Util.xs"
char *outstr;
#line 467 "Util.c"
SV * RETVAL;
#line 220 "Util.xs"
outstr = plperl_sv_to_literal(sv, typname);
if (outstr == NULL)
RETVAL = &PL_sv_undef;
else
RETVAL = cstr2sv(outstr);
#line 475 "Util.c"
RETVAL = sv_2mortal(RETVAL);
ST(0) = RETVAL;
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_PostgreSQL__InServer__Util); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_PostgreSQL__InServer__Util)
{
#if PERL_VERSION_LE(5, 21, 5)
dVAR; dXSARGS;
#else
dVAR; dXSBOOTARGSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
char* file = __FILE__;
#else
const char* file = __FILE__;
#endif
PERL_UNUSED_VAR(file);
PERL_UNUSED_VAR(cv); /* -W */
PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5) && defined(XS_APIVERSION_BOOTCHECK)
XS_APIVERSION_BOOTCHECK;
#endif
cv = newXSproto_portable("DEBUG", XS___aliased_constants, file, "");
XSANY.any_i32 = DEBUG2;
cv = newXSproto_portable("ERROR", XS___aliased_constants, file, "");
XSANY.any_i32 = ERROR;
cv = newXSproto_portable("INFO", XS___aliased_constants, file, "");
XSANY.any_i32 = INFO;
cv = newXSproto_portable("LOG", XS___aliased_constants, file, "");
XSANY.any_i32 = LOG;
cv = newXSproto_portable("NOTICE", XS___aliased_constants, file, "");
XSANY.any_i32 = NOTICE;
cv = newXSproto_portable("WARNING", XS___aliased_constants, file, "");
XSANY.any_i32 = WARNING;
cv = newXSproto_portable("_aliased_constants", XS___aliased_constants, file, "");
XSANY.any_i32 = 0;
(void)newXSproto_portable("elog", XS__elog, file, "$$");
(void)newXSproto_portable("quote_literal", XS__quote_literal, file, "$");
(void)newXSproto_portable("quote_nullable", XS__quote_nullable, file, "$");
(void)newXSproto_portable("quote_ident", XS__quote_ident, file, "$");
(void)newXSproto_portable("decode_bytea", XS__decode_bytea, file, "$");
(void)newXSproto_portable("encode_bytea", XS__encode_bytea, file, "$");
(void)newXSproto_portable("looks_like_number", XS__looks_like_number, file, "$");
(void)newXSproto_portable("encode_typed_literal", XS__encode_typed_literal, file, "$$");
/* Initialisation Section */
#line 229 "Util.xs"
items = 0; /* avoid 'unused variable' warning */
#line 535 "Util.c"
/* End of Initialisation Section */
#if PERL_VERSION_LE(5, 21, 5)
# if PERL_VERSION_GE(5, 9, 0)
if (PL_unitcheckav)
call_list(PL_scopestack_ix, PL_unitcheckav);
# endif
XSRETURN_YES;
#else
Perl_xs_boot_epilog(aTHX_ ax);
#endif
}
Christoph Berg <myon@debian.org> writes:
The only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)
Can we see the Perl-related output from configure, particularly the new
lines about CFLAGS?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Re: Tom Lane 2017-07-31 <30582.1501508356@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The only interesting line in log/postmaster.log is a log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got handshake key 0xd500080, needed 0xd600080)Can we see the Perl-related output from configure, particularly the new
lines about CFLAGS?
$ ./configure --with-perl
checking whether to build Perl modules... yes
checking for perl... /usr/bin/perl
configure: using perl 5.26.0
checking for Perl archlibexp... /usr/lib/x86_64-kfreebsd-gnu/perl/5.26
checking for Perl privlibexp... /usr/share/perl/5.26
checking for Perl useshrplib... true
checking for CFLAGS recommended by Perl... -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
checking for CFLAGS to compile embedded Perl... -DDEBIAN
checking for flags to link embedded Perl... -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lc -lcrypt
checking for perl.h... yes
checking for libperl... yes
Christoph
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Hi
An update from beta3 build: We are no longer seeing this issue (handshake
failure) on Windows 64bit, but on Windows 32bit it still persists.
On Mon, Jul 31, 2017 at 10:15 PM, Christoph Berg <myon@debian.org> wrote:
Re: Tom Lane 2017-07-31 <30582.1501508356@sss.pgh.pa.us>
Christoph Berg <myon@debian.org> writes:
The only interesting line in log/postmaster.log is a
log_line_prefix-less
Util.c: loadable library and perl binaries are mismatched (got
handshake key 0xd500080, needed 0xd600080)
Can we see the Perl-related output from configure, particularly the new
lines about CFLAGS?$ ./configure --with-perl
checking whether to build Perl modules... yes
checking for perl... /usr/bin/perl
configure: using perl 5.26.0
checking for Perl archlibexp... /usr/lib/x86_64-kfreebsd-gnu/perl/5.26
checking for Perl privlibexp... /usr/share/perl/5.26
checking for Perl useshrplib... true
checking for CFLAGS recommended by Perl... -D_REENTRANT -D_GNU_SOURCE
-DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
checking for CFLAGS to compile embedded Perl... -DDEBIAN
checking for flags to link embedded Perl... -fstack-protector-strong
-L/usr/local/lib -L/usr/lib/x86_64-kfreebsd-gnu/perl/5.26/CORE -lperl
-ldl -lm -lpthread -lc -lcryptchecking for perl.h... yes
checking for libperl... yesChristoph
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Sandeep Thakkar
EDB
On Tue, Aug 8, 2017 at 8:37 AM, Sandeep Thakkar
<sandeep.thakkar@enterprisedb.com> wrote:
An update from beta3 build: We are no longer seeing this issue (handshake
failure) on Windows 64bit, but on Windows 32bit it still persists.
Hmm, maybe you should've reported it sooner, so we could've tried to
fix this before beta3 went out.
What was the exact message you saw, including the hex values?
Is the Perl you were building against for plperl the same Perl that
was being used for the build itself?
Do you have the portion of the build log where src/pl/plperl was being built?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Aug 8, 2017 at 8:19 PM, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Aug 8, 2017 at 8:37 AM, Sandeep Thakkar
<sandeep.thakkar@enterprisedb.com> wrote:An update from beta3 build: We are no longer seeing this issue (handshake
failure) on Windows 64bit, but on Windows 32bit it still persists.Hmm, maybe you should've reported it sooner, so we could've tried to
fix this before beta3 went out.Yes, that would have been better. The patch was tested only on Windows
64bit and we never thought that it won't work on 32bit.
What was the exact message you saw, including the hex values?
Attach is the screenshot of the contents of the postmaster log that was
sent to me by one of my team members who was testing this.
Is the Perl you were building against for plperl the same Perl that
was being used for the build itself?Yes.
Do you have the portion of the build log where src/pl/plperl was being
built?I copied and pasted that portion of the build log into file build.log
(attached) for Windows 32bit and Windows 64bit.
Thanks.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sandeep Thakkar
EDB
Attachments:
handshare_win32.pngimage/png; name=handshare_win32.pngDownload
�PNG
IHDR � 7�� iCCPICC Profile H���T����+)������� �J��`#$B�!T����kAEEEW@\ ����E��**+�b����$�>��y��9�}�����&3��@��%d�
d�s���^���D&��@��#0c�s�!���� ����s���-�n $r2'��� �:[ ���
�z�rb~YY@$�9U�bN����':�� d*�%L@N����N�y��-��N�n�4r/�)YYs!�S!'�'�?r&O�d�R'X:I!��r����t����)�CVj�0 R<f8o�s���#m���p�J���81�M����s��� (��|�!��D���1�f %��
��F�q�pn�X~4���5�i��������a�\����Wz$?-:N������A�����<��0?�;l�G(�k���6E�)��T�r���Y�Y
��=r����X<7'>d\���+��q���1�\]^�c�E���1����)�g�`N^�x��\�����=JgEH�c���Rm8B�7�L �5����5�<I[� A*��1�xD����Q � �r&��$�\��_&���9H���I"2�S�Y�:����!���5��;��1��{%�}�D?���6T� ���n�IxJ�!<"� ���`���c+�O�,<�d�=�W �A9��^�76�d=0��B�v��
�C�8W��-�'��f��+M��6�?�'�����r�rvc*�'�{Ox�����9��w����*�0v;�]���f��Nb-�e���'V��J�-R�-����X�[X~�[��1B��
r��s��{�`��������_d.3��������r @�}�~>�0$�m�q��-� �bhL�fc�p�) �w�lz���Z��n�H�'���P�<�j@�c8&k`\��A D�0�z�����E`9(%`=�*�����hm�8.�np��k�� C�A���:��h#�b�8"n�/�D" H����Y�� �H��C~E�!��Hr�C���'C��2���SQG�
F��Yh*������Z��F��M�)�z�E_���d1���c��7�%b)�[�ceX5��������
bq"N���9\�x����%������N����_ 4����L$�R �E�2�^�Q���� ��D"�hDt�{3��N\H\C�Nl$�{����$I�dFr%��X�\Ri+i?�$�*����,K�&[����d>��\F�G>A�J~F�Q�1�q� ���,�Y'�G�U��L��E�bDq�DS�)�)����}�YYY]Y'���<�e���e����~�*QM����Tu-���N�C}C��i�DZ.m-��v����A�.g!(��[*W)�$wU���������l�|�2���W�d�X
K*�)�RV�+Z)�+f)�Q��xA��I�P�W��T��[���c:F��{����=�3�~e���r�r�r���.�!%[�X��*�*�Uz����d�cb�d|��9�sw��I
��Nz�:Y�C��Z���zC��S�W-Cm�Z��u\�T}��<�*�3����'�LfO.�|h�]
T�T#Rc��n����Z�������5�ZZ�Z��Nh
h����y���Oj��Taz23���N����N��Hg�N�����n�n�n��=���^��&��!}m�P�E���w
d
���3xohdg��������Q�Q�Q��}c���q�q��u���I��v�nS���4�����jfo�3�n�3�0�i
J��[�TsO�<�z�>�E�E�E�����S�n�zn�WK;�L�=�������
�Z�^[�Z��+����l�l������5���V������������b�`/�o�p�wHr��p�Q�1�q��y'����R�6����������r1w�p���|��4��=�����\w���1���v���������y�yp<�z<�4�L�������K�u������b�v�������W�7�������_�_������B�� B@p���[�������� ���A��������G!�!���P44(tc��0�0~Xs8�� �(";������+�?���\y.�5'j_��h��u��b�cD1���3c�b��������O�_)A=����HJ�M��8<�w���3�f��9�h��Yf����}|�����I����}I�Y��j�pr`���!�7{�����3�u��r������<OuM��:���V�6���U�^���H��Q�1����E�J�:�W�g�;�j��?�G`&(�f;go��� 9�rZr��Q���X���/�-�2����y��+������t������Y�/d/�X��h������w-A�$/�X���pi�2�e��)�3��^`YPZ�vE���B��e������H�HXtk�����U�U]�mVo]���S|����������?[�\������]���U�'������}Cm�bi~�����617oz�y��e�e;�P��������l���~������^���4����~;g��*����;Jv|���y{����j������y�����s��_����-����_�[Y�Y�PW�Oc��z�^T?����>Z�v52K���������C��:;n8bpd�Q���&�iA�PsZsoKBK���c�.�G����M������u'('
O���?9�.h<�z�q���{��O_����u&����~gO��<w�������]t��|��R�e��G���h�}W��+-�N��=�zN\u�z�������_�v��f����f�������N��Ww����[v�p���������e���^���}>}�E=��������'������=�~V���y���@�3��!x12X�����^�<���_�����_ _��^�F�M�[�����e�y_�A�C�G���>�}z62�3�s��/�_������,�Q �MI�u
�xv��8����%)���(!�O,��I�= 5 �, �Q�`5�L�o��;��66u����XKsQ�-��at��&