Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sokK7-00DVpx-Nn for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2024 13:57:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sokK7-008thv-8E for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2024 13:57:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sokK6-008thn-Ng for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2024 13:57:26 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sokK2-000pP1-3n for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2024 13:57:26 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-6bf7ad1ec3aso7159276d6.0 for ; Thu, 12 Sep 2024 06:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1726149441; x=1726754241; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:references:cc:to:from :subject:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=YCn3d2aYFRMFbXRUwqMSBz+7fZz7ieeca6Y1nCWoKQA=; b=WTmvL0E7SumpWmpxsFe6Vu2s/LFepsWSW+CB7iiDlmABHG18xNO6niEaM/vN/ZHbtv tTBBqJGVAI/Ard4vPuhxO8QO4ySK0MQyPPfCM7icPhVC/R7FWw2fnO8mPJz54jhNagRY soe//aDp98dXRc8RDlRo6wPs0N4vKmbt6WuAWT5Y1ANpCCy/DWCe0rMcQYRLdshQny1/ 1vP2CdtS8BYJCzf0hVCg5XXRQ0uZZ09v45C5GMtyzMc6b9fixtxvj0MRfRBHsQzr9/5a hSYfPqStvh+TXNiflQElHdxAPakmxCEjqbYDfBw+YUg728yriamiH2jxnmIiww95R2Rw FK/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726149441; x=1726754241; h=in-reply-to:autocrypt:content-language:references:cc:to:from :subject:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YCn3d2aYFRMFbXRUwqMSBz+7fZz7ieeca6Y1nCWoKQA=; b=vT7OWQ1M5Yirqw0NDfmY1e0DTRz+hDBNjjY4njk9uXR/3OjFgBejH4ggq4pY11HtVk gF7BOHpM9yzxeZG5CyPmh4vlDWv3KlRyv3R5XPZJz0Df+nQ2YPnBMtCoC23c7WZbf16B TB+yAnf5Ms1mSWVwhmQoXuLreKaBMNGEYImu6oxUkrZQU4LImwbennTHX7tEJ7EoE8Nq vsp6ddYG0eYv3b3VWju1mSBFiRKALh/HgYvggavnBPXJ9/+w5mN4xrtOmomxPt3KD85W Fd+CPj+oCaicr5cBHKx6I1jVb4harDQ6L12W28MAiwbA6JtyKBzg/WFOV8pKZ0P9nc5L aJLw== X-Gm-Message-State: AOJu0Yx7tGqoaPYzfTNu+JUz0NG8CKh19ViBQQvDEjOin7G826YtsCZI smDqX2tM50lg2LrU2P/qDsKv3CXVYQzsPJSau1cMHfInmZjH8MBpeKotCBZh9kNz2MzfZVOIfo6 t X-Google-Smtp-Source: AGHT+IES31veue+8frPR03/5J5RKFUO5ZG/EmUYiUgFxIzIJA1+a7RdOc/wRP1eFrQyCJxMp9NXRAg== X-Received: by 2002:a05:6214:5c02:b0:6c3:5c75:d2b6 with SMTP id 6a1803df08f44-6c57351ac5emr43421396d6.22.1726149440457; Thu, 12 Sep 2024 06:57:20 -0700 (PDT) Received: from ?IPV6:2605:a601:9180:9800::2bb? ([2605:a601:9180:9800::2bb]) by smtp.googlemail.com with ESMTPSA id 6a1803df08f44-6c534339a7dsm54273676d6.47.2024.09.12.06.57.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Sep 2024 06:57:19 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------NfeRrG9xmn1oPu0Eq09YjoW5" Message-ID: Date: Thu, 12 Sep 2024 09:57:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pl/perl extension fails on Windows From: Andrew Dunstan To: Muralikrishna Bandaru Cc: pgsql-bugs@lists.postgresql.org References: <35af00d5-0cc6-4c22-9367-5af3b50ee96b@dunslane.net> <11f06540-85a8-4fbc-8922-b03bf9ef92b7@dunslane.net> Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNJEFuZHJldyBEdW5zdGFuIDxhbmRyZXdAZHVuc2xhbmUubmV0PsLAmwQTAQgARQIbAwIX gAIZAQULCQgHAgMiAgEGFQoJCAsCBBYCAwECHgcWIQTkPlhGHfx8v0RpFaWZ+n/LWfw7gQUC ZFlxxwUJGVGAbgAKCRCZ+n/LWfw7gXikB/9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7Q8hwQpL+4C6GNpb6ZKnPkLi47pDOLhz2qBrqN+rqUEsT3YnExYpzj5yOBi+FlmV1Hw 49QYe1sn2ZPs In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------NfeRrG9xmn1oPu0Eq09YjoW5 Content-Type: multipart/alternative; boundary="------------70y6ej2MU1PDha5bup9joiqz" --------------70y6ej2MU1PDha5bup9joiqz Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-09-11 We 7:36 AM, Andrew Dunstan wrote: > > > On 2024-09-11 We 3:37 AM, Muralikrishna Bandaru wrote: >> >> >> On Tue, Sep 10, 2024 at 7:17 PM Andrew Dunstan >> wrote: >> >> >> On 2024-09-10 Tu 7:51 AM, Andrew Dunstan wrote: >>> >>> >>> On 2024-09-10 Tu 6:20 AM, Muralikrishna Bandaru wrote: >>>> Hi, >>>> I built PG17 rc1 using meson on Windows with the option >>>> "-Dplperl=enabled" . When I tried to create the extension,it >>>> crashed 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. >>>> >>>> The log contains the following error. >>>> >>>> *src/pl/plperl/Util.c: loadable library and perl binaries are >>>> mismatched (got first handshake key 0000000012d00080, needed >>>> 0000000012c00080)* >>>> -- >>>> This issue is seen with strawberry perl *5.40* not with *5.38* >>>> . The Perl that is used during compilation and on the target >>>> machine is the same. >>>> >>>> I have used strawberry perl 5.40 , which is available in the >>>> strawberry perl home page  ,but  >>>> 5.40 is not available in the release page >>>> . So, is it >>>> recommended to use  perl 5.40 ? >>>> >>>> Please let me know if you need any other information. >>> >>> >>> We've seen similar things before. See for example: >>> >>> https://postgr.es/m/20211005004334.tgjmro4kuachwiuc@alap3.anarazel.de >>> https://postgr.es/m/c2da86a0-2906-744c-923d-16da6047875e@dunslane.net >>> >>> This looks like we are defining something we should not be, or >>> not defining something we should be. We just need to find out >>> what it is :-) >>> >>> In the meantime, I would suggest sticking to 5.38. >>> >>> >>> >> >> >> Now I've had a chance to take a look I see that Strawberry 5.40 >> has USE_THREAD_SAFE_LOCALE defined. Can you try what happens with >> 5.40 if you comment out theses lines in meson.build? >> >> >>       if cc.get_id() == 'msvc' >>         # prevent binary mismatch between MSVC built plperl and >> Strawberry or >>         # msys ucrt perl libraries >>         perl_ccflags += ['-DNO_THREAD_SAFE_LOCALE'] >>       endif >> >> >> Hi Andrew, >> Thanks. I commented above lines in the meson.build file and built the >> installer with  Strawberry 5.40 . Now able to create the extension. >> -- >> c:\Program Files\PostgreSQL\17>bin\psql.exe -d postgres -p 5436 >> psql (17rc1) >> WARNING: Console code page (437) differs from Windows code page (1252) >>          8-bit characters might not work correctly. See psql reference >>          page "Notes for Windows users" for details. >> Type "help" for help. >> >> postgres=# >> postgres=# >> postgres=# create extension plperl; >> -- >> So, will this change be a part of the PG17 GA release? >> >> > > Probably not. The difficulty is that it's required for some versions > of perl and breaks others. We need to come up with a reliable test for it. > > Maybe we need to look at the output of `perl -V` and only output the > flag if it doesn't contain USE_THREAD_SAFE_LOCALE. If anyone has a > better idea I am all ears. > > It's kind of annoying that this could tie us so closely to a > particular perl binary. > > > Here's a patch along the suggested lines. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------70y6ej2MU1PDha5bup9joiqz Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2024-09-11 We 7:36 AM, Andrew Dunstan wrote:


On 2024-09-11 We 3:37 AM, Muralikrishna Bandaru wrote:


On Tue, Sep 10, 2024 at 7:17 PM Andrew Dunstan <andrew@dunslane.net> wrote:


On 2024-09-10 Tu 7:51 AM, Andrew Dunstan wrote:


On 2024-09-10 Tu 6:20 AM, Muralikrishna Bandaru wrote:
Hi,
I built PG17 rc1 using meson on Windows with the option "-Dplperl=enabled" . When I tried to create the extension,it crashed 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.

The log contains the following error.

src/pl/plperl/Util.c: loadable library and perl binaries are mismatched (got first handshake key 0000000012d00080, needed 0000000012c00080)
--
This issue is seen with strawberry perl 5.40 not with 5.38 . The Perl that is used during compilation and on the target machine is the same.

I have used strawberry perl 5.40 , which is available in the strawberry perl  home page ,but  5.40 is not available in the release page . So, is it recommended to use  perl 5.40 ?

Please let me know if you need any other information.


We've seen similar things before. See for example:

https://postgr.es/m/20211005004334.tgjmro4kuachwiuc@alap3.anarazel.de
https://postgr.es/m/c2da86a0-2906-744c-923d-16da6047875e@dunslane.net

This looks like we are defining something we should not be, or not defining something we should be. We just need to find out what it is :-)

In the meantime, I would suggest sticking to 5.38.





Now I've had a chance to take a look I see that Strawberry 5.40 has USE_THREAD_SAFE_LOCALE defined. Can you try what happens with 5.40 if you comment out theses lines in meson.build?


      if cc.get_id() == 'msvc'
        # prevent binary mismatch between MSVC built plperl and Strawberry or
        # msys ucrt perl libraries
        perl_ccflags += ['-DNO_THREAD_SAFE_LOCALE']
      endif


Hi Andrew,
Thanks. I commented above lines in the meson.build file and built the installer with  Strawberry 5.40 . Now able to create the extension.
--
c:\Program Files\PostgreSQL\17>bin\psql.exe -d postgres -p 5436
psql (17rc1)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=#
postgres=#
postgres=# create extension plperl;
--
So, will this change be a part of the PG17 GA release?



Probably not. The difficulty is that it's required for some versions of perl and breaks others. We need to come up with a reliable test for it.

Maybe we need to look at the output of `perl -V` and only output the flag if it doesn't contain USE_THREAD_SAFE_LOCALE. If anyone has a better idea I am all ears.

It's kind of annoying that this could tie us so closely to a particular perl binary.




Here's a patch along the suggested lines.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------70y6ej2MU1PDha5bup9joiqz-- --------------NfeRrG9xmn1oPu0Eq09YjoW5 Content-Type: text/x-patch; charset=UTF-8; name="perl-locales-fix.patch" Content-Disposition: attachment; filename="perl-locales-fix.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL21lc29uLmJ1aWxkIGIvbWVzb24uYnVpbGQKaW5kZXggNDc2NGIwOTI2 Ni4uZjk2NDI1YTYxZSAxMDA2NDQKLS0tIGEvbWVzb24uYnVpbGQKKysrIGIvbWVzb24uYnVp bGQKQEAgLTEwNTYsOSArMTA1NiwxMiBAQCBpZiBub3QgcGVybG9wdC5kaXNhYmxlZCgpCiAg ICAgICBwZXJsX2NjZmxhZ3MgKz0gWyctRFBMUEVSTF9IQVZFX1VJRF9HSUQnXQogCiAgICAg ICBpZiBjYy5nZXRfaWQoKSA9PSAnbXN2YycKLSAgICAgICAgIyBwcmV2ZW50IGJpbmFyeSBt aXNtYXRjaCBiZXR3ZWVuIE1TVkMgYnVpbHQgcGxwZXJsIGFuZCBTdHJhd2JlcnJ5IG9yCi0g ICAgICAgICMgbXN5cyB1Y3J0IHBlcmwgbGlicmFyaWVzCi0gICAgICAgIHBlcmxfY2NmbGFn cyArPSBbJy1ETk9fVEhSRUFEX1NBRkVfTE9DQUxFJ10KKyAgICAgICAgcGVybF92ID0gcnVu X2NvbW1hbmQocGVybCwgJy1WJykuc3Rkb3V0KCkKKyAgICAgICAgaWYgbm90IHBlcmxfdi5j b250YWlucygnVVNFX1RIUkVBRF9TQUZFX0xPQ0FMRScpCisgICAgICAgICAgIyBwcmV2ZW50 IGJpbmFyeSBtaXNtYXRjaCBiZXR3ZWVuIE1TVkMgYnVpbHQgcGxwZXJsIGFuZCBTdHJhd2Jl cnJ5IG9yCisgICAgICAgICAgIyBtc3lzIHVjcnQgcGVybCBsaWJyYXJpZXMKKyAgICAgICAg ICBwZXJsX2NjZmxhZ3MgKz0gWyctRE5PX1RIUkVBRF9TQUZFX0xPQ0FMRSddCisgICAgICAg IGVuZGlmCiAgICAgICBlbmRpZgogICAgIGVuZGlmCiAK --------------NfeRrG9xmn1oPu0Eq09YjoW5--