Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

why does par packer cause incorrect Perl-Tk server() output?

by perltux (Monk)
on Feb 16, 2018 at 10:38 UTC ( [id://1209281] : perlquestion . print w/replies, xml ) Need Help??

perltux has asked for the wisdom of the Perl Monks concerning the following question:

Given the following script:

use strict; use warnings; use Tk; my $mw=MainWindow->new(); print STDOUT "PerlTk server: [". $mw->server() ."]\n";

If I run the above script on Windows 10 using StrawberryPerl I get the following output which is as expected:

PerlTk server: [Windows 10.0 10586 Win32]

but if I create an exe of the above script with Par::Packer on the same system I get the following wrong output when running the exe:

PerlTk server: [Windows 6.2 9200 Win32]

Why does Par::Packer change the output of the Tk 'server()' command making it incorrect and what do I have to do to get the correct output when using an exe created by Par::Packer?

Replies are listed 'Best First'.
Re: why does par packer cause incorrect Perl-Tk server() output?
by marto (Cardinal) on Feb 16, 2018 at 11:36 UTC

    Release NT 6.2 is Windows 8, the latest build of which is 9200 (source). Run the following perl script:

    #!/usr/bin/perl use strict; use warnings; use feature 'say'; use Win32; say Win32::GetOSName(); say Win32::GetOSVersion();

    package (pp -x -o OSver.exe script.pl), execute and compare the output.

    Update: see issue with a depreciated API.

      Output from your script:

      Win10Business (64-bit) 100105862002561


      output from par packed exe of your script:

      Win8Professional (64-bit) 6292002002561


      so same issue with the Win32 module, when par packed.

        Time to start digging through pp, PAR to find the root cause.

Re: why does par packer cause incorrect Perl-Tk server() output?
by Discipulus (Canon) on Feb 16, 2018 at 11:38 UTC
    > Why does Par::Packer..

    sorry I dont know the cause and I tried to investigate a bit without success..

    I confirm the same behaviour on my machine (win10 strawberry perl 5.26): it returns 6.2.9200 aka Windows Server 2012 or Windows 8

    But, if I recall it correctly when I read Mastering Perl Tk in paragrhap 13.11.6. Server Type it was a sentences similar to:

    An ancient Win32 machine has a server type of "Windows 4". Anyway thi +s information is generally inconsistent, if not wrong, so think of i +t as suspecious data.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thanks for confirming the issue, at least I now know it's not just my machine or software setup.
Re: why does par packer cause incorrect Perl-Tk server() output?
by perltux (Monk) on Feb 16, 2018 at 18:57 UTC
    I found a solution that fixes the problem, not sure if it's just a workaround or a 'proper' solution as I don't know much about Windows specific programming.

    I added the <compatibility> section of the manifest file found here:
    https://msdn.microsoft.com/windows/compatibility/operating-system-version-changes-in-windows-8-1
    to the myldr/winres/pp.manifest file in the PAR-Packer-1.041 source, and then rebuilt and reinstalled PAR-Packer from the modified source.

    Any exe built with this modified PAR-Packer displays the Windows version info correctly (tested on Win 10 and 8.1).

    For the record, this is the section I added to the pp.manifest file:

    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!-- Windows Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!-- Windows 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!-- Windows 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> </application> </compatibility>
Re: why does par packer cause incorrect Perl-Tk server() output?
by perltux (Monk) on Feb 16, 2018 at 11:45 UTC
    The point that puzzles me is that the PerlTK server() call does provide the correct output when run directly, but not when packed inside a Par::Packer exe, so it's not a matter of depreciated APIs or ancient warnings from a 16 year old book.

    It appears like a Par::Packer bug to me, but I don't have enough knowledge or skill to pinpoint the root cause.
      It appears like a Par::Packer bug to me, but I don't have enough knowledge or skill to pinpoint the root cause.

      You don't have to. All you need is enough knowledge or skill to raise a bug report. The maintainer will then investigate for you.

        I have submitted the bug report now: https://rt.cpan.org/Public/Bug/Display.html?id=124445
Re: why does par packer cause incorrect Perl-Tk server() output?
by Anonymous Monk on Feb 16, 2018 at 11:22 UTC
    Its just baked in exe meaningless strings? Use Win32 module for real info?
      Why would Par::Packer mess with the Perl-Tk server() function output?

      Besides a quick grep through the Par::Packer source does not reveal a matching baked in string.

      And I don't want to use the Win32 module because the program is supposed to run on Linux too, the PerlTk server() function is platform independent.
        How does tk generate that string(source)? It uses some %env or some exe property... Thats all par could possibly mess with as is its job... Unless it comes from windir dll which shouldnt have been ppacked...